private void SerializeListItem(PdListBase pdList, object item, string key, IJsonWriter jsonWriter) { if (item == null) { if (key == null) { jsonWriter.Write(null); } else { jsonWriter.Write(key, null); } } else if (pdList.ItemFabric.IsSimple) { if (key == null) { jsonWriter.Write(pdList.ItemFabric.GetValueAsString(item)); } else { jsonWriter.Write(key, pdList.ItemFabric.GetValueAsString(item)); } } else { using (var jw = jsonWriter.WriteClass(key)) { Serialize(item, jw); } } }
private void SerializeList(object obj, PdListBase pdList, IJsonWriter jsonWriter) { var list = pdList.PropertyFabric.GetValue <IList>(obj); if (list == null) { jsonWriter.Write(pdList.NodeName, null); } else { using (var jw = jsonWriter.WriteArray(pdList.NodeName)) { foreach (var itm in list) { SerializeListItem(pdList, itm, null, jw); } } } }
private object DeserializeListItem(PdListBase pd, JsonObjectBase jsonData) { object item = null; if (jsonData is JsonObjectSimple) { var jsonSimple = jsonData as JsonObjectSimple; if (jsonSimple.Value != null) { item = pd.ItemFabric.StringToObject(jsonSimple.Value); } } else if (jsonData is JsonObjectClass) { var jsonClass = jsonData as JsonObjectClass; item = pd.ItemFabric.CreateInstance(); Deserialize(item, jsonClass.Class); } return(item); }