Пример #1
0
        // -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        /// <summary>
        /// Builds the xml fragment representing the properties of the RssCoreItem class
        /// </summary>
        /// <param name="parEl"></param>
        // -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        public void SetEl(XElement parEl)
        {
            RssRfc822DateTimeConverter dtConvert = new RssRfc822DateTimeConverter();

            if (title.Length > 0)
            {
                xUtil.AddEl(parEl, TAG_TITLE, title);
            }
            if (link.Length > 0)
            {
                xUtil.AddEl(parEl, TAG_LINK, link);
            }
            if (description.Length > 0)
            {
                xUtil.AddEl(parEl, TAG_DESCRIPTION, WebUtility.HtmlEncode(description));
            }
            if (author.Length > 0)
            {
                xUtil.AddEl(parEl, TAG_AUTHOR, author);
            }


            if (categories.Count > 0)
            {
                for (int i = 0; i < categories.Count; i++)
                {
                    XElement ctgEl = categories[i].GetEl();
                    parEl.Add(ctgEl);
                }
            }


            if (comments.Length > 0)
            {
                xUtil.AddEl(parEl, TAG_COMMENTS, WebUtility.HtmlEncode(comments));
            }

            if (enclosures.Count > 0)
            {
                for (int i = 0; i < enclosures.Count; i++)
                {
                    XElement enclosureEl = enclosures[i].GetEl();
                    parEl.Add(enclosureEl);
                }
            }

            if (guid != null)
            {
                XElement guidEl = guid.GetEl();
                parEl.Add(guidEl);
            }


            if (pubDate != DateTime.MinValue)
            {
                xUtil.AddEl(parEl, TAG_PUBDATE, dtConvert.FormatDateTime(pubDate));
            }


            if (source != null)
            {
                XElement sourceEl = source.GetEl();
                parEl.Add(sourceEl);
            }
        }
Пример #2
0
        // -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        /// <summary>
        /// Sets the element with the descendents of the parent XElement
        /// </summary>
        /// <param name="parEl"></param>
        /// <returns></returns>
        // -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        public void SetEl(XElement parEl)
        {
            RssRfc822DateTimeConverter dtConvert = new RssRfc822DateTimeConverter();

            // channel title
            xUtil.AddEl(parEl, TAG_TITLE, title);

            // link to channel
            xUtil.AddEl(parEl, TAG_LINK, link);

            // channel description
            xUtil.AddEl(parEl, TAG_DESCRIPTION, WebUtility.HtmlEncode(description));

            // optional elements are only included if they are not null or have string length
            // greater than zero or in the case of dates, greater that datetime.minvalue

            // language
            if (language.Length > 0)
            {
                xUtil.AddEl(parEl, TAG_LANGUAGE, language);
            }

            // copyright
            if (copyright.Length > 0)
            {
                xUtil.AddEl(parEl, TAG_COPYRIGHT, copyright);
            }

            // managing editor
            if (managingEditor.Length > 0)
            {
                xUtil.AddEl(parEl, TAG_MANAGINGEDITOR, managingEditor);
            }

            // webmaster
            if (webMaster.Length > 0)
            {
                xUtil.AddEl(parEl, TAG_WEBMASTER, webMaster);
            }

            if (pubDate != DateTime.MinValue)
            {
                xUtil.AddEl(parEl, TAG_PUBDATE, dtConvert.FormatDateTime(pubDate));
            }

            if (lastBuildDate != DateTime.MinValue)
            {
                xUtil.AddEl(parEl, TAG_LASTBUILDDATE, dtConvert.FormatDateTime(lastBuildDate));
            }


            // applicable categories
            if (categories.Count > 0)
            {
                for (int i = 0; i < categories.Count; i++)
                {
                    XElement el = categories[i].GetEl();
                    parEl.Add(el);
                }
            }


            // arrogance
            if (generator.Length == 0)
            {
                generator = RSS.GENERATOR;
            }


            // generator
            if (generator.Length > 0)
            {
                xUtil.AddEl(parEl, TAG_GENERATOR, generator);
            }

            if (docs.Length > 0)
            {
                xUtil.AddEl(parEl, TAG_DOCS, docs);
            }

            // multiple cloud interfaces allowed here
            if (cloud.Count > 0)
            {
                for (int i = 0; i < cloud.Count; i++)
                {
                    XElement cloudEl = cloud[i].GetEl();
                    parEl.Add(cloudEl);
                }
            }

            if (ttl > 0)
            {
                xUtil.AddEl(parEl, TAG_TTL, ttl);
            }

            if (image != null)
            {
                XElement imageEl = image.GetEl();
                parEl.Add(imageEl);
            }

            if (textInput != null)
            {
                XElement textInputEl = textInput.GetEl();
                parEl.Add(textInputEl);
            }

            if (skipHours != null)
            {
                if (skipHours.Hours.Count > 0)
                {
                    XElement skipHoursEl = skipHours.GetEl();
                    parEl.Add(skipHoursEl);
                }
            }

            if (skipDays != null)
            {
                if (skipDays.Days.Count > 0)
                {
                    XElement skipDaysEl = skipDays.GetEl();
                    parEl.Add(skipDaysEl);
                }
            }
        }