zhaojs
2023-09-15 fc13938ff90213060532d99a600dea4a84456885
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace YouZanSDKStandard.Api
{
    public class YouZanDictionary : Dictionary<string, string>
    {
         // Fields
        private const string DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
 
        // Methods
        public YouZanDictionary()
        {
        }
 
        public YouZanDictionary(IDictionary<string, string> dictionary)
            : base(dictionary)
        {
        }
 
        public void Add(string key, object value)
        {
            string str;
            if (value == null)
            {
                str = null;
            }
            else if (value is string)
            {
                str = (string)value;
            }
            else if (value is DateTime?)
            {
                DateTime? nullable = value as DateTime?;
                str = nullable.Value.ToString("yyyy-MM-dd HH:mm:ss");
            }
            else if (value is int?)
            {
                int? nullable2 = value as int?;
                str = nullable2.Value.ToString();
            }
            else if (value is long?)
            {
                long? nullable3 = value as long?;
                str = nullable3.Value.ToString();
            }
            else if (value is double?)
            {
                double? nullable4 = value as double?;
                str = nullable4.Value.ToString();
            }
            else if (value is bool?)
            {
                bool? nullable5 = value as bool?;
                str = nullable5.Value.ToString().ToLower();
            }
            else
            {
                str = value.ToString();
            }
            this.AddValue(key, str);
        }
 
        public void AddValue(string key, string value)
        {
            if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
            {
                base.Add(key, value);
            }
        }
 
        public void AddAll(IDictionary<string, string> dict)
        {
            if ((dict != null) && (dict.Count > 0))
            {
                IEnumerator<KeyValuePair<string, string>> enumerator = dict.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    KeyValuePair<string, string> current = enumerator.Current;
                    this.AddValue(current.Key, current.Value);
                }
            }
        }
 
    }
}