Esempio n. 1
0
 /// <summary>
 /// 创建字典
 /// </summary>
 /// <typeparam name="T">转换的实体</typeparam>
 /// <typeparam name="T1">要序列化的类型</typeparam>
 /// <param name="objectJsonItems">ObjectJsonItem</param>
 /// <returns>json字符串</returns>
 public static T1 CreateDictionary <T, T1>(params ObjectJsonItem <T>[] objectJsonItems) where T1 : IDictionary, new ()
 {
     if (objectJsonItems.Length == 0)
     {
         return(new T1());
     }
     else
     {
         T1 t1 = new T1();
         foreach (var objectJsonItem in objectJsonItems)
         {
             t1.Add(objectJsonItem.Key, objectJsonItem.Value);
         }
         return(t1);
     }
 }