static IXMLElement InternalConstructor(IXMLDocument doc, string name, params INode[] children) { IXMLElement x = doc.createElement(name); if (children.Length > 0) { x.appendChild(children); } return(x); }
static IXMLElement InternalConstructor(IXMLDocument doc, string name, string value) { IXMLElement n = doc.createElement(name); if (value != null) { n.appendChild(new ITextNode(doc, value)); } return(n); }
Expando DeserializeTo(IXMLElement r, string name) { if (KnownTypes[name] == null) { return(null); } Expando z = KnownTypes[name].CreateType(); foreach (IXMLElement x in r.childNodes) { if (x.nodeType == INode.NodeTypeEnum.ElementNode) { if (z.Metadata[x.nodeName] == null) { z.SetMember(x.nodeName, x.innerXML); } else { if (z.Metadata[x.nodeName].IsArray) { IArray <object> a = new IArray <object>(); foreach (IXMLElement xx in x.childNodes) { if (xx.nodeType == INode.NodeTypeEnum.ElementNode) { a += DeserializeTo(xx, xx.nodeName); } } z.SetMember(x.nodeName, a); } else { z.SetMember(x.nodeName, DeserializeTo(x, z.Metadata[x.nodeName].GetValue())); } } } } return(z); }
void SerializeTo(IXMLDocument doc, IXMLElement r, Expando x) { ExpandoMember[] c = x.GetFields(); foreach (ExpandoMember m in c) { IXMLElement n = new IXMLElement(doc, m.Name); if (m.Self.IsString || (m.Self.IsNumber)) { n.appendChild(new ITextNode(doc, m.Value)); } else { if (m.Self.IsBoolean) { n.appendChild(new ITextNode(doc, m.Value)); } else if (m.Self.IsArray) { Expando[] a = m.Self.To <Expando[]>(); foreach (Expando i in a) { IXMLElement an = new IXMLElement(doc, i.TypeMetaName); SerializeTo(doc, an, i); n.appendChild(an); } } else if (m.Self.IsObject && (!m.Self.IsNull)) { SerializeTo(doc, n, m.Self); } } r.appendChild(n); } }