private void SerializeNodes(object obj, IJsonWriter jsonWriter) { foreach (var info in _types[obj.GetType()].Nodes) { if (info.Value is PdClass) { var pdClass = info.Value as PdClass; var instance = pdClass.PropertyFabric.GetValue <object>(obj); if (instance == null) { jsonWriter.Write(pdClass.NodeName, null); } else { using (var jw = jsonWriter.WriteClass(pdClass.NodeName)) { Serialize(instance, jw); } } } if (info.Value is PdList) { var pdList = info.Value as PdList; SerializeList(obj, pdList, jsonWriter); } if (info.Value is PdDictionary) { var pdDict = info.Value as PdDictionary; SerializeDict(obj, pdDict, jsonWriter); } } }
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); } } }