| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System;
- using System.Collections.Generic;
- namespace Essensoft.AspNetCore.Payment.LianLianPay
- {
- /// <summary>
- /// LianLianPay 字典。
- /// </summary>
- public class LianLianPayDictionary : SortedDictionary<string, string>
- {
- private const string DATE_TIME_FORMAT = "yyyyMMddHHmmss";
- public LianLianPayDictionary() { }
- public LianLianPayDictionary(IDictionary<string, string> dictionary)
- : base(dictionary)
- { }
- public void Add(string key, object value)
- {
- string strValue;
- if (value == null)
- {
- strValue = null;
- }
- else if (value is string)
- {
- strValue = (string)value;
- }
- else if (value is DateTime?)
- {
- var dateTime = value as DateTime?;
- strValue = dateTime.Value.ToString(DATE_TIME_FORMAT);
- }
- else if (value is int?)
- {
- strValue = (value as int?).Value.ToString();
- }
- else if (value is long?)
- {
- strValue = (value as long?).Value.ToString();
- }
- else if (value is double?)
- {
- strValue = (value as double?).Value.ToString();
- }
- else if (value is bool?)
- {
- strValue = (value as bool?).Value.ToString().ToLower();
- }
- else
- {
- strValue = value.ToString();
- }
- Add(key, strValue);
- }
- public new void Add(string key, string value)
- {
- if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value))
- {
- base.Add(key, value);
- }
- }
- }
- }
|