예제 #1
0
 public object GetObjectToSerialize(object obj, Type targetType)
 {
     if (obj.GetType() == typeof(T))
     {
         var json = DataContractJsonSerializerHelper.GetJson((T)obj, new DataContractJsonSerializerSettings {
             UseSimpleDictionaryFormat = true
         });
         var dict  = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize <Dictionary <string, string> >(json);
         var array = new ListDictionaryArray();
         array.AddRange(dict.Select(pair => new[] { pair }.ToDictionary(p => p.Key, p => p.Value)));
         return(array);
     }
     return(obj);
 }