using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace YouZanSDKStandard.Api { public class YouZanDictionary : Dictionary { // Fields private const string DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; // Methods public YouZanDictionary() { } public YouZanDictionary(IDictionary 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 dict) { if ((dict != null) && (dict.Count > 0)) { IEnumerator> enumerator = dict.GetEnumerator(); while (enumerator.MoveNext()) { KeyValuePair current = enumerator.Current; this.AddValue(current.Key, current.Value); } } } } }