Exemple #1
0
        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);
        }
        static Expando DeserializeAsExpando(INode e)
        {
            Expando x = new Expando();

            foreach (IXMLElement v in e.childNodes)
            {
                x.SetMember(v.nodeName, DeserializeAsValue(v));
            }

            return(x);
        }
Exemple #3
0
        public IXMLSerializer(params object[] k)
        {
            if (k == null)
            {
                throw new Exception("IXMLSerializer: k is null");
            }

            foreach (object x in k)
            {
                Expando o = Expando.Of(x);

                KnownTypes.SetMember(o.TypeMetaName, o);
            }
        }