public override bool ProcessStartElement(string name, string prefix = null, string namespaceUri = null) { if (IsDeserializing) { return(CurrentXmlElement.Name == name); } else { XmlElement newElement; if (prefix == null || namespaceUri == null) { newElement = Document.CreateElement(name); } else { newElement = Document.CreateElement(prefix, name, namespaceUri); } if (CurrentXmlElement == null) { Document.InsertBefore(newElement, null); } else { CurrentXmlElement.AppendChild(newElement); } CurrentXmlElement = newElement; return(true); } }
public override bool ProcessAttributeString(string name, Action <string> readAction, Func <string> writeFunc) { if (IsDeserializing) { if (!CurrentXmlElement.HasAttribute(name)) { return(false); } string xmlValue = CurrentXmlElement.GetAttribute(name); readAction(xmlValue); } else { string xmlValue = writeFunc(); if (!String.IsNullOrEmpty(xmlValue)) { CurrentXmlElement.SetAttribute(name, xmlValue); } } return(true); }