コード例 #1
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a GsaExtension object.</summary> 
        /// <param name="node">the node to parse node</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created GsaExtension object</returns>
        //////////////////////////////////////////////////////////////////////
        public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();
            GsaExtension gsa = null;

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

            gsa = new GsaExtension();
            
            if (node != null)
            {
                if (node.Attributes == null || node.Attributes[PropertyName] == null)
                {
                    throw new ArgumentException("GsaContent name can not found in this name space");
                }
                gsa.ContentName = node.Attributes[PropertyName].Value;
                gsa.ContentValue = node.InnerText == null ? "" : node.InnerText;
            }
            return gsa;
        }
コード例 #2
0
        /// <summary>
        /// Add another set of extension data to the entry.  Each GSA extension stores 
        /// the content as a mixed text/XML content of this XML tag.
        /// addGsaContent does not support repeating extension data with 
        /// the same extension name.  Even though addGsaContent will successfully
        /// add repeating extensions, there is no guarantee which of the repeating
        /// extensions with the same extension name will be returned by methods
        /// GetGsaContent() and GetAllGsaContents().
        /// </summary>
        /// <param name="name">name of the content extension</param>
        /// <param name="content">content data of the extension</param>
        public void AddGsaContent(string name, string content)
        {
            GsaExtension extension = new GsaExtension(name, content);
            this.ExtensionElements.Add(extension);

        }