Пример #1
0
        // -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        /// <summary>
        /// Loads the media group properties with the content of the XElement
        /// </summary>
        /// <param name="parEl">XElement</param>
        // -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        public void Load(XElement parEl)
        {
            if (parEl.Name.Namespace == RSS.MEDIA_NS ||
                parEl.Name.Namespace == RSS.DUBLIN_CORE_TERMS_NS ||
                parEl.Name.Namespace == RSS.GEORSS_NS ||
                parEl.Name.Namespace == RSS.GML_NS)
            {
                IEnumerable <XElement> lst = parEl.Elements();
                foreach (XElement el in lst)
                {
                    switch (el.Name.LocalName)
                    {
                    case TAG_MEDIACONTENT:
                        RssMediaContent mc = new RssMediaContent(this);
                        mc.Load(el);
                        mediaContentItems.Add(mc);
                        break;

                    // load the media options if any exist for the media group element
                    default:
                        mediaOptions.LoadEl(el);
                        break;
                    }
                }
            }
        }
Пример #2
0
        // -------------------------------------------------------------------------------
        // -------------------------------------------------------------------------------
        /// <summary>
        /// Loads the RssItem object from the XElement
        /// </summary>
        /// <param name="el">Current Element</param>
        private new void LoadEl(XElement el)
        {
            // if the el is a core element, load from the base
            if (el.Name.Namespace == XNamespace.None)
            {
                base.LoadEl(el);
            }

            // if the el is in the media namespace or the dublin core terms namespace, load what we know.
            else if (el.Name.Namespace == RSS.MEDIA_NS || el.Name.Namespace == RSS.DUBLIN_CORE_TERMS_NS)
            {
                switch (el.Name.LocalName)
                {
                case RssMediaGroup.TAG_PARENT:
                    RssMediaGroup mediaGroup = new RssMediaGroup(this);
                    mediaGroup.Load(el);
                    mediaGroups.Add(mediaGroup);
                    break;


                case RssMediaContent.TAG_PARENT:
                    RssMediaContent mediaContent = new RssMediaContent(this);
                    mediaContent.Load(el);
                    mediaContentItems.Add(mediaContent);
                    break;


                default:
                    mediaOptions.LoadEl(el);
                    break;
                }
            }

            // if the element is in the DublinCoreNS, load what we know
            else if (el.Name.Namespace == RSS.DUBLIN_CORE_NS)
            {
                switch (el.Name.LocalName)
                {
                case RssDublinCoreCreator.TAG_PARENT:
                    RssDublinCoreCreator creator = new RssDublinCoreCreator();
                    creator.Load(el);
                    creators.Add(creator);
                    break;
                }
            }

            // is the element in the Content Namespace, if so, process it
            else if (el.Name.Namespace == RSS.CONTENT_NS)
            {
                switch (el.Name.LocalName)
                {
                case RssContentEncoded.TAG_PARENT:
                    ContentEncoded = new RssContentEncoded();
                    ContentEncoded.Load(el);
                    break;
                }
            }

            else if (el.Name.Namespace == RSS.SLASH_NS)
            {
                switch (el.Name.LocalName)
                {
                case RssSlashComments.TAG_PARENT:
                    SlashComments = new RssSlashComments();
                    SlashComments.Load(el);
                    break;
                }
            }

            else if (el.Name.Namespace == RSS.CREATIVE_COMMONS_NS)
            {
                switch (el.Name.LocalName)
                {
                case RssCreativeCommonsLicense.TAG_PARENT:
                    CreativeCommonsLicense = new RssCreativeCommonsLicense();
                    CreativeCommonsLicense.Load(el);
                    break;
                }
            }
        }