Esempio n. 1
0
        /// <summary>
        /// Adds the or replace the optional feed reference element.
        /// </summary>
        /// <param name="newsItem">The news item.</param>
        /// <param name="feedUrl">The feed URL.</param>
        /// <param name="sourceID">The source ID.</param>
        /// <returns></returns>
        public static XmlElement AddOrReplaceOriginalFeedReference(INewsItem newsItem, string feedUrl, int sourceID)
        {
            if (newsItem == null)
            {
                throw new ArgumentNullException("newsItem");
            }

            XmlQualifiedName key     = AdditionalElements.GetQualifiedName(OriginalFeedRef);
            XmlQualifiedName attrKey = AdditionalElements.GetQualifiedName(OriginalSourceID);

            if (newsItem.OptionalElements == null)
            {
                newsItem.OptionalElements = new Dictionary <XmlQualifiedName, string>(2);
            }

            if (newsItem.OptionalElements.ContainsKey(key))
            {
                newsItem.OptionalElements.Remove(key);
            }

            XmlElement element = RssHelper.CreateXmlElement(Prefix, key, feedUrl);

            element.Attributes.Append(RssHelper.CreateXmlAttribute(String.Empty, attrKey, sourceID.ToString()));
            newsItem.OptionalElements.Add(key, element.OuterXml);

            return(element);
        }