Example #1
0
        /// <summary>
        /// Modifies the secondary collections of a <see cref="IYahooMediaCommonObjectEntities"/> to match the data source.
        /// </summary>
        /// <param name="target">The object that implements the <see cref="IYahooMediaCommonObjectEntities"/> interface to be filled.</param>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract Yahoo media common entity information from.</param>
        /// <param name="manager">The <see cref="XmlNamespaceManager"/> object used to resolve prefixed Yahoo media elements and attributes.</param>
        /// <returns><b>true</b> if the <paramref name="target"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="target"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="manager"/> is a null reference (Nothing in Visual Basic).</exception>
        private static bool FillCommonObjectEntityCollectionsSecondary(IYahooMediaCommonObjectEntities target, XPathNavigator source, XmlNamespaceManager manager)
        {
            bool wasLoaded = false;

            Guard.ArgumentNotNull(target, "target");
            Guard.ArgumentNotNull(source, "source");
            Guard.ArgumentNotNull(manager, "manager");

            if (source.HasChildren)
            {
                XPathNodeIterator hashIterator        = source.Select("media:hash", manager);
                XPathNodeIterator restrictionIterator = source.Select("media:restriction", manager);
                XPathNodeIterator textIterator        = source.Select("media:text", manager);

                if (hashIterator != null && hashIterator.Count > 0)
                {
                    while (hashIterator.MoveNext())
                    {
                        YahooMediaHash hash = new YahooMediaHash();
                        if (hash.Load(hashIterator.Current))
                        {
                            target.Hashes.Add(hash);
                            wasLoaded = true;
                        }
                    }
                }

                if (restrictionIterator != null && restrictionIterator.Count > 0)
                {
                    while (restrictionIterator.MoveNext())
                    {
                        YahooMediaRestriction restriction = new YahooMediaRestriction();
                        if (restriction.Load(restrictionIterator.Current))
                        {
                            target.Restrictions.Add(restriction);
                            wasLoaded = true;
                        }
                    }
                }

                if (textIterator != null && textIterator.Count > 0)
                {
                    while (textIterator.MoveNext())
                    {
                        YahooMediaText text = new YahooMediaText();
                        if (text.Load(textIterator.Current))
                        {
                            target.TextSeries.Add(text);
                            wasLoaded = true;
                        }
                    }
                }
            }

            return(wasLoaded);
        }
Example #2
0
        /// <summary>
        /// Modifies the secondary collections of a <see cref="IYahooMediaCommonObjectEntities"/> to match the data source.
        /// </summary>
        /// <param name="target">The object that implements the <see cref="IYahooMediaCommonObjectEntities"/> interface to be filled.</param>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract Yahoo media common entity information from.</param>
        /// <param name="manager">The <see cref="XmlNamespaceManager"/> object used to resolve prefixed Yahoo media elements and attributes.</param>
        /// <returns><b>true</b> if the <paramref name="target"/> was initialized using the supplied <paramref name="source"/>, otherwise <b>false</b>.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="target"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="manager"/> is a null reference (Nothing in Visual Basic).</exception>
        private static bool FillCommonObjectEntityCollectionsSecondary(IYahooMediaCommonObjectEntities target, XPathNavigator source, XmlNamespaceManager manager)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasLoaded  = false;

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

            //------------------------------------------------------------
            //	Attempt to extract common entity information
            //------------------------------------------------------------
            if(source.HasChildren)
            {
                XPathNodeIterator hashIterator          = source.Select("media:hash", manager);
                XPathNodeIterator restrictionIterator   = source.Select("media:restriction", manager);
                XPathNodeIterator textIterator          = source.Select("media:text", manager);

                if (hashIterator != null && hashIterator.Count > 0)
                {
                    while (hashIterator.MoveNext())
                    {
                        YahooMediaHash hash = new YahooMediaHash();
                        if (hash.Load(hashIterator.Current))
                        {
                            target.Hashes.Add(hash);
                            wasLoaded   = true;
                        }
                    }
                }

                if (restrictionIterator != null && restrictionIterator.Count > 0)
                {
                    while (restrictionIterator.MoveNext())
                    {
                        YahooMediaRestriction restriction   = new YahooMediaRestriction();
                        if (restriction.Load(restrictionIterator.Current))
                        {
                            target.Restrictions.Add(restriction);
                            wasLoaded   = true;
                        }
                    }
                }

                if (textIterator != null && textIterator.Count > 0)
                {
                    while (textIterator.MoveNext())
                    {
                        YahooMediaText text = new YahooMediaText();
                        if (text.Load(textIterator.Current))
                        {
                            target.TextSeries.Add(text);
                            wasLoaded   = true;
                        }
                    }
                }
            }

            return wasLoaded;
        }