Esempio n. 1
0
        /// <summary>
        /// Loads this <see cref="ITunesOwner"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="ITunesOwner"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="ITunesOwner"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            bool wasLoaded = false;

            Guard.ArgumentNotNull(source, "source");
            ITunesSyndicationExtension extension = new ITunesSyndicationExtension();
            XmlNamespaceManager        manager   = extension.CreateNamespaceManager(source);

            if (source.HasChildren)
            {
                XPathNavigator emailNavigator = source.SelectSingleNode("itunes:email", manager);
                XPathNavigator nameNavigator  = source.SelectSingleNode("itunes:name", manager);

                if (emailNavigator != null && !String.IsNullOrEmpty(emailNavigator.Value))
                {
                    this.EmailAddress = emailNavigator.Value;
                    wasLoaded         = true;
                }

                if (nameNavigator != null && !String.IsNullOrEmpty(nameNavigator.Value))
                {
                    this.Name = nameNavigator.Value;
                    wasLoaded = true;
                }
            }

            return(wasLoaded);
        }
Esempio n. 2
0
        //============================================================
        //	PUBLIC METHODS
        //============================================================
        #region Load(XPathNavigator source)
        /// <summary>
        /// Loads this <see cref="ITunesCategory"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="ITunesCategory"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="ITunesCategory"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasLoaded = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");

            //------------------------------------------------------------
            //	Create namespace manager to resolve prefixed elements
            //------------------------------------------------------------
            ITunesSyndicationExtension extension = new ITunesSyndicationExtension();
            XmlNamespaceManager        manager   = extension.CreateNamespaceManager(source);

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            if (source.HasAttributes)
            {
                string textAttribute = source.GetAttribute("text", String.Empty);
                if (!String.IsNullOrEmpty(textAttribute))
                {
                    this.Text = textAttribute;
                    wasLoaded = true;
                }
            }

            if (source.HasChildren)
            {
                XPathNodeIterator categoryIterator = source.Select("itunes:category", manager);

                if (categoryIterator != null && categoryIterator.Count > 0)
                {
                    while (categoryIterator.MoveNext())
                    {
                        ITunesCategory category = new ITunesCategory();
                        if (category.Load(categoryIterator.Current))
                        {
                            this.Categories.Add(category);
                            wasLoaded = true;
                        }
                    }
                }
            }

            return(wasLoaded);
        }
Esempio n. 3
0
        //============================================================
        //	PUBLIC METHODS
        //============================================================
        #region Load(XPathNavigator source)
        /// <summary>
        /// Loads this <see cref="ITunesOwner"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="ITunesOwner"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="ITunesOwner"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasLoaded = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");

            //------------------------------------------------------------
            //	Create namespace manager to resolve prefixed elements
            //------------------------------------------------------------
            ITunesSyndicationExtension extension = new ITunesSyndicationExtension();
            XmlNamespaceManager        manager   = extension.CreateNamespaceManager(source);

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            if (source.HasChildren)
            {
                XPathNavigator emailNavigator = source.SelectSingleNode("itunes:email", manager);
                XPathNavigator nameNavigator  = source.SelectSingleNode("itunes:name", manager);

                if (emailNavigator != null && !String.IsNullOrEmpty(emailNavigator.Value))
                {
                    this.EmailAddress = emailNavigator.Value;
                    wasLoaded         = true;
                }

                if (nameNavigator != null && !String.IsNullOrEmpty(nameNavigator.Value))
                {
                    this.Name = nameNavigator.Value;
                    wasLoaded = true;
                }
            }

            return(wasLoaded);
        }
        /// <summary>
        /// Loads this <see cref="ITunesCategory"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="ITunesCategory"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="ITunesCategory"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            bool wasLoaded = false;

            Guard.ArgumentNotNull(source, "source");
            ITunesSyndicationExtension extension = new ITunesSyndicationExtension();
            XmlNamespaceManager        manager   = extension.CreateNamespaceManager(source);

            if (source.HasAttributes)
            {
                string textAttribute = source.GetAttribute("text", String.Empty);
                if (!String.IsNullOrEmpty(textAttribute))
                {
                    this.Text = textAttribute;
                    wasLoaded = true;
                }
            }

            if (source.HasChildren)
            {
                XPathNodeIterator categoryIterator = source.Select("itunes:category", manager);

                if (categoryIterator != null && categoryIterator.Count > 0)
                {
                    while (categoryIterator.MoveNext())
                    {
                        ITunesCategory category = new ITunesCategory();
                        if (category.Load(categoryIterator.Current))
                        {
                            this.Categories.Add(category);
                            wasLoaded = true;
                        }
                    }
                }
            }

            return(wasLoaded);
        }
Esempio n. 5
0
        /// <summary>
        /// Loads this <see cref="ITunesOwner"/> using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <returns><b>true</b> if the <see cref="ITunesOwner"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="ITunesOwner"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasLoaded              = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");

            //------------------------------------------------------------
            //	Create namespace manager to resolve prefixed elements
            //------------------------------------------------------------
            ITunesSyndicationExtension extension    = new ITunesSyndicationExtension();
            XmlNamespaceManager manager             = extension.CreateNamespaceManager(source);

            //------------------------------------------------------------
            //	Attempt to extract syndication information
            //------------------------------------------------------------
            if (source.HasChildren)
            {
                XPathNavigator emailNavigator   = source.SelectSingleNode("itunes:email", manager);
                XPathNavigator nameNavigator    = source.SelectSingleNode("itunes:name", manager);

                if (emailNavigator != null && !String.IsNullOrEmpty(emailNavigator.Value))
                {
                    this.EmailAddress   = emailNavigator.Value;
                    wasLoaded           = true;
                }

                if (nameNavigator != null && !String.IsNullOrEmpty(nameNavigator.Value))
                {
                    this.Name   = nameNavigator.Value;
                    wasLoaded   = true;
                }
            }

            return wasLoaded;
        }