Exemplo n.º 1
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a Who object.</summary>
        /// <param name="node">the xml parses node, can be NULL</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created SimpleElement object</returns>
        //////////////////////////////////////////////////////////////////////
        public override IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();

            SimpleElement e = null;

            if (node != null)
            {
                object localname = node.LocalName;
                if (localname.Equals(this.XmlName) == false ||
                    node.NamespaceURI.Equals(this.XmlNameSpace) == false)
                {
                    return(null);
                }
            }

            // memberwise close is fine here, as everything is identical beside the value
            e = this.MemberwiseClone() as SimpleElement;
            e.InitInstance(this);

            if (node != null)
            {
                e.Value = node.InnerText;
            }

            e.ProcessAttributes(node);
            e.ProcessChildNodes(node, parser);

            return(e);
        }
        /// <summary>Parses an xml node to create an instance object.</summary>
        /// <param name="node">the parsed xml node, can be NULL</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created SimpleElement object</returns>
        public override IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();

            SimpleElement e = null;

            if (node != null)
            {
                object localname = node.LocalName;
                if (!localname.Equals(this.XmlName) ||
                    !node.NamespaceURI.Equals(this.XmlNameSpace))
                {
                    return(null);
                }
            }

            // memberwise close is fine here, as everything is identical besides the value
            e = this.MemberwiseClone() as SimpleElement;
            e.InitInstance(this);

            if (node != null)
            {
                e.ProcessAttributes(node);
                if (node.HasChildNodes)
                {
                    XmlNode n = node.ChildNodes[0];
                    if (n.NodeType == XmlNodeType.Text && node.ChildNodes.Count == 1)
                    {
                        e.Value = node.InnerText;
                    }
                    else
                    {
                        e.ProcessChildNodes(node, parser);
                    }
                }
            }

            return(e);
        }