private void InternalWriteXml(object writer, object receiver, WriteSettings settings, XElement current, string modelName) { ObjectInfo info = ObjectInfo.Create(receiver, modelName); if (info.IsObjectContext) { TkDebug.ThrowIfNoGlobalVariable(); BaseGlobalVariable.Current.ObjectContext.Push(receiver); } foreach (var attr in info.Attributes) { SerializerUtil.WritePropertyInfo(this, writer, receiver, settings, attr, current); } if (info.Content != null) { SerializerUtil.WritePropertyInfo(this, writer, receiver, settings, info.Content, current); } else { SerializerUtil.WriteChildElement(this, writer, info.Elements, settings, receiver, (objValue, propInfo) => propInfo.GetValue(objValue), current); } if (info.IsObjectContext) { BaseGlobalVariable.Current.ObjectContext.Pop(); } }
public void WriteTagElement(TagElementAttribute attribute, object writer, object value, WriteSettings settings, ObjectPropertyInfo info, object serializerData) { var current = serializerData.Convert <XElement>(); XElement element = new XElement(info.QName.ToXName()); current.Add(element); SerializerUtil.WriteChildElement(this, writer, attribute.ChildElements, settings, value, (objValue, propInfo) => value, element); }
public void WriteTagElement(TagElementAttribute attribute, object writer, object value, WriteSettings settings, ObjectPropertyInfo info, object serializerData) { XmlWriter xmlWriter = writer.Convert <XmlWriter>(); PrefixTable prefixTable = serializerData.Convert <PrefixTable>(); WriteStartElement(xmlWriter, info.QName, prefixTable); SerializerUtil.WriteChildElement(this, writer, attribute.ChildElements, settings, value, (objValue, propInfo) => value, prefixTable); xmlWriter.WriteEndElement(); }
public void WriteObject(object writer, object receiver, string modelName, WriteSettings settings, QName root, object serializerData) { XmlWriter xmlWriter = writer.Convert <XmlWriter>(); var prefixTable = serializerData.Convert <PrefixTable>(); WriteStartElement(xmlWriter, root, prefixTable); ObjectInfo info = ObjectInfo.Create(receiver, modelName); if (info.IsObjectContext) { TkDebug.ThrowIfNoGlobalVariable(); BaseGlobalVariable.Current.ObjectContext.Push(receiver); } foreach (var attr in info.Attributes) { SerializerUtil.WritePropertyInfo(this, writer, receiver, settings, attr, prefixTable); } if (info.Content != null) { SerializerUtil.WritePropertyInfo(this, writer, receiver, settings, info.Content, prefixTable); } else { SerializerUtil.WriteChildElement(this, writer, info.Elements, settings, receiver, (objValue, propInfo) => propInfo.GetValue(objValue), prefixTable); } if (info.IsObjectContext) { BaseGlobalVariable.Current.ObjectContext.Pop(); } xmlWriter.WriteEndElement(); }