コード例 #1
0
        // end of accessor public SortedList GadgetPreferences


        #region WebContent Parser

        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a webcontent object.</summary> 
        /// <param name="node">xml node</param>
        /// <param name="parser">the atomfeedparser to use for deep dive parsing</param>
        /// <returns>the created SimpleElement object</returns>
        //////////////////////////////////////////////////////////////////////
        public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser) 
        {
            Tracing.TraceCall();

            if (node != null)
            {
                object localname = node.LocalName;
                if (localname.Equals(this.XmlName) == false ||
                    node.NamespaceURI.Equals(this.XmlNameSpace) == false)
                {
                    return null;
                }
            }
            
            WebContent webContent = null;
          
            webContent = new WebContent();
            if (node.Attributes != null)
            {
                String value = node.Attributes[GDataParserNameTable.XmlAttributeUrl] != null ? 
                    node.Attributes[GDataParserNameTable.XmlAttributeUrl].Value : null; 
                if (value != null)
                {
                    webContent.Url = value;
                }

                value = node.Attributes[GDataParserNameTable.XmlAttributeDisplay] != null ?
                    node.Attributes[GDataParserNameTable.XmlAttributeDisplay].Value : null;
                if (value != null)
                {
                    webContent.Display = value;
                }

                value = node.Attributes[GDataParserNameTable.XmlAttributeWidth] != null ? 
                    node.Attributes[GDataParserNameTable.XmlAttributeWidth].Value : null; 

                if (value != null)
                {
                    webContent.Width = uint.Parse(value, System.Globalization.NumberStyles.Integer, CultureInfo.InvariantCulture);
                }

                value = node.Attributes[GDataParserNameTable.XmlAttributeHeight] != null ? 
                    node.Attributes[GDataParserNameTable.XmlAttributeHeight].Value : null; 

                if (value != null)
                {
                    webContent.Height = uint.Parse(value, System.Globalization.NumberStyles.Integer, CultureInfo.InvariantCulture);
                }
            }
              // single event, g:reminder is inside g:when
            if (node.HasChildNodes)
            {
                XmlNode gadgetPrefs = node.FirstChild;
                while (gadgetPrefs != null && gadgetPrefs is XmlElement)
                {
                    if (String.Compare(gadgetPrefs.NamespaceURI, XmlNameSpace, true) == 0)
                    {
                        if (String.Compare(gadgetPrefs.LocalName, GDataParserNameTable.XmlWebContentGadgetElement) == 0)
                        {
                            if (gadgetPrefs.Attributes != null)
                            {
                                string value = gadgetPrefs.Attributes[BaseNameTable.XmlValue] != null ? 
                                               gadgetPrefs.Attributes[BaseNameTable.XmlValue].Value : null;

                                string name  = gadgetPrefs.Attributes[BaseNameTable.XmlName] != null ?
                                               gadgetPrefs.Attributes[BaseNameTable.XmlName].Value : null;

                                if (name != null)
                                {
                                    webContent.GadgetPreferences.Add(name, value);
                                }
                            }
                        }
                    }
                    gadgetPrefs = gadgetPrefs.NextSibling;
                }
            }
            return webContent;
        }
コード例 #2
0
        // end of accessor public SortedList GadgetPreferences


        #region WebContent Parser

        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a webcontent object.</summary>
        /// <param name="node">xml node</param>
        /// <param name="parser">the atomfeedparser to use for deep dive parsing</param>
        /// <returns>the created SimpleElement object</returns>
        //////////////////////////////////////////////////////////////////////
        public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();

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

            WebContent webContent = null;

            webContent = new WebContent();
            if (node.Attributes != null)
            {
                String value = node.Attributes[GDataParserNameTable.XmlAttributeUrl] != null ?
                               node.Attributes[GDataParserNameTable.XmlAttributeUrl].Value : null;
                if (value != null)
                {
                    webContent.Url = value;
                }

                value = node.Attributes[GDataParserNameTable.XmlAttributeDisplay] != null ?
                        node.Attributes[GDataParserNameTable.XmlAttributeDisplay].Value : null;
                if (value != null)
                {
                    webContent.Display = value;
                }

                value = node.Attributes[GDataParserNameTable.XmlAttributeWidth] != null ?
                        node.Attributes[GDataParserNameTable.XmlAttributeWidth].Value : null;

                if (value != null)
                {
                    webContent.Width = uint.Parse(value, System.Globalization.NumberStyles.Integer, CultureInfo.InvariantCulture);
                }

                value = node.Attributes[GDataParserNameTable.XmlAttributeHeight] != null ?
                        node.Attributes[GDataParserNameTable.XmlAttributeHeight].Value : null;

                if (value != null)
                {
                    webContent.Height = uint.Parse(value, System.Globalization.NumberStyles.Integer, CultureInfo.InvariantCulture);
                }
            }
            // single event, g:reminder is inside g:when
            if (node.HasChildNodes)
            {
                XmlNode gadgetPrefs = node.FirstChild;
                while (gadgetPrefs != null && gadgetPrefs is XmlElement)
                {
                    if (String.Compare(gadgetPrefs.NamespaceURI, XmlNameSpace, true) == 0)
                    {
                        if (String.Compare(gadgetPrefs.LocalName, GDataParserNameTable.XmlWebContentGadgetElement) == 0)
                        {
                            if (gadgetPrefs.Attributes != null)
                            {
                                string value = gadgetPrefs.Attributes[BaseNameTable.XmlValue] != null ?
                                               gadgetPrefs.Attributes[BaseNameTable.XmlValue].Value : null;

                                string name = gadgetPrefs.Attributes[BaseNameTable.XmlName] != null ?
                                              gadgetPrefs.Attributes[BaseNameTable.XmlName].Value : null;

                                if (name != null)
                                {
                                    webContent.GadgetPreferences.Add(name, value);
                                }
                            }
                        }
                    }
                    gadgetPrefs = gadgetPrefs.NextSibling;
                }
            }
            return(webContent);
        }