Beispiel #1
0
        //============================================================
        //	ICOMPARABLE IMPLEMENTATION
        //============================================================
        #region CompareTo(object obj)
        /// <summary>
        /// Compares the current instance with another object of the same type.
        /// </summary>
        /// <param name="obj">An object to compare with this instance.</param>
        /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns>
        /// <exception cref="ArgumentException">The <paramref name="obj"/> is not the expected <see cref="Type"/>.</exception>
        public int CompareTo(object obj)
        {
            //------------------------------------------------------------
            //	If target is a null reference, instance is greater
            //------------------------------------------------------------
            if (obj == null)
            {
                return(1);
            }

            //------------------------------------------------------------
            //	Determine comparison result using property state of objects
            //------------------------------------------------------------
            YahooMediaGroup value = obj as YahooMediaGroup;

            if (value != null)
            {
                int result = YahooMediaUtility.CompareSequence(this.Contents, value.Contents);

                result = result | YahooMediaUtility.CompareCommonObjectEntities(this, value);

                return(result);
            }
            else
            {
                throw new ArgumentException(String.Format(null, "obj is not of type {0}, type was found to be '{1}'.", this.GetType().FullName, obj.GetType().FullName), "obj");
            }
        }
        //============================================================
        //	PUBLIC METHODS
        //============================================================
        #region Load(XPathNavigator source, XmlNamespaceManager manager)
        /// <summary>
        /// Initializes the syndication extension context using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <b>XPathNavigator</b> used to load this <see cref="YahooMediaSyndicationExtensionContext"/>.</param>
        /// <param name="manager">The <see cref="XmlNamespaceManager"/> object used to resolve prefixed syndication extension elements and attributes.</param>
        /// <returns><b>true</b> if the <see cref="YahooMediaSyndicationExtensionContext"/> was able to be initialized using the supplied <paramref name="source"/>; otherwise <b>false</b>.</returns>
        /// <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>
        public bool Load(XPathNavigator source, XmlNamespaceManager manager)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasLoaded = false;

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

            //------------------------------------------------------------
            //	Attempt to extract syndication extension information
            //------------------------------------------------------------
            if (source.HasChildren)
            {
                XPathNodeIterator contentIterator = source.Select("media:content", manager);
                XPathNodeIterator groupIterator   = source.Select("media:group", manager);

                if (contentIterator != null && contentIterator.Count > 0)
                {
                    while (contentIterator.MoveNext())
                    {
                        YahooMediaContent content = new YahooMediaContent();
                        if (content.Load(contentIterator.Current))
                        {
                            this.AddContent(content);
                            wasLoaded = true;
                        }
                    }
                }

                if (groupIterator != null && groupIterator.Count > 0)
                {
                    while (groupIterator.MoveNext())
                    {
                        YahooMediaGroup group = new YahooMediaGroup();
                        if (group.Load(groupIterator.Current))
                        {
                            this.AddGroup(group);
                            wasLoaded = true;
                        }
                    }
                }
            }

            if (YahooMediaUtility.FillCommonObjectEntities(this, source))
            {
                wasLoaded = true;
            }

            return(wasLoaded);
        }
        /// <summary>
        /// Adds the supplied <see cref="YahooMediaGroup"/> to the current instance's <see cref="Groups"/> collection.
        /// </summary>
        /// <param name="group">The <see cref="YahooMediaGroup"/> to be added.</param>
        /// <returns><b>true</b> if the <see cref="YahooMediaGroup"/> was added to the <see cref="Groups"/> collection, otherwise <b>false</b>.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="group"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool AddGroup(YahooMediaGroup group)
        {
            bool wasAdded = false;

            Guard.ArgumentNotNull(group, "group");

            ((Collection <YahooMediaGroup>) this.Groups).Add(group);
            wasAdded = true;

            return(wasAdded);
        }
        /// <summary>
        /// Removes the supplied <see cref="YahooMediaGroup"/> from the current instance's <see cref="Groups"/> collection.
        /// </summary>
        /// <param name="group">The <see cref="YahooMediaGroup"/> to be removed.</param>
        /// <returns><b>true</b> if the <see cref="YahooMediaGroup"/> was removed from the <see cref="Groups"/> collection, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     If the <see cref="Groups"/> collection of the current instance does not contain the specified <see cref="YahooMediaGroup"/>, will return <b>false</b>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="group"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool RemoveGroup(YahooMediaGroup group)
        {
            bool wasRemoved = false;

            Guard.ArgumentNotNull(group, "group");

            if (((Collection <YahooMediaGroup>) this.Groups).Contains(group))
            {
                ((Collection <YahooMediaGroup>) this.Groups).Remove(group);
                wasRemoved = true;
            }

            return(wasRemoved);
        }
        /// <summary>
        /// Initializes the syndication extension context using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <b>XPathNavigator</b> used to load this <see cref="YahooMediaSyndicationExtensionContext"/>.</param>
        /// <param name="manager">The <see cref="XmlNamespaceManager"/> object used to resolve prefixed syndication extension elements and attributes.</param>
        /// <returns><b>true</b> if the <see cref="YahooMediaSyndicationExtensionContext"/> was able to be initialized using the supplied <paramref name="source"/>; otherwise <b>false</b>.</returns>
        /// <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>
        public bool Load(XPathNavigator source, XmlNamespaceManager manager)
        {
            bool wasLoaded = false;

            Guard.ArgumentNotNull(source, "source");
            Guard.ArgumentNotNull(manager, "manager");
            if (source.HasChildren)
            {
                XPathNodeIterator contentIterator = source.Select("media:content", manager);
                XPathNodeIterator groupIterator   = source.Select("media:group", manager);

                if (contentIterator != null && contentIterator.Count > 0)
                {
                    while (contentIterator.MoveNext())
                    {
                        YahooMediaContent content = new YahooMediaContent();
                        if (content.Load(contentIterator.Current))
                        {
                            this.AddContent(content);
                            wasLoaded = true;
                        }
                    }
                }

                if (groupIterator != null && groupIterator.Count > 0)
                {
                    while (groupIterator.MoveNext())
                    {
                        YahooMediaGroup group = new YahooMediaGroup();
                        if (group.Load(groupIterator.Current))
                        {
                            this.AddGroup(group);
                            wasLoaded = true;
                        }
                    }
                }
            }

            if (YahooMediaUtility.FillCommonObjectEntities(this, source))
            {
                wasLoaded = true;
            }

            return(wasLoaded);
        }
        /// <summary>
        /// Adds the supplied <see cref="YahooMediaGroup"/> to the current instance's <see cref="Groups"/> collection.
        /// </summary>
        /// <param name="group">The <see cref="YahooMediaGroup"/> to be added.</param>
        /// <returns><b>true</b> if the <see cref="YahooMediaGroup"/> was added to the <see cref="Groups"/> collection, otherwise <b>false</b>.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="group"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool AddGroup(YahooMediaGroup group)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasAdded = false;

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

            //------------------------------------------------------------
            //	Add media group to collection
            //------------------------------------------------------------
            ((Collection <YahooMediaGroup>) this.Groups).Add(group);
            wasAdded = true;

            return(wasAdded);
        }
Beispiel #7
0
        /// <summary>
        /// Compares the current instance with another object of the same type.
        /// </summary>
        /// <param name="obj">An object to compare with this instance.</param>
        /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns>
        /// <exception cref="ArgumentException">The <paramref name="obj"/> is not the expected <see cref="Type"/>.</exception>
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            YahooMediaGroup value = obj as YahooMediaGroup;

            if (value != null)
            {
                int result = YahooMediaUtility.CompareSequence(this.Contents, value.Contents);

                result = result | YahooMediaUtility.CompareCommonObjectEntities(this, value);

                return(result);
            }
            else
            {
                throw new ArgumentException(String.Format(null, "obj is not of type {0}, type was found to be '{1}'.", this.GetType().FullName, obj.GetType().FullName), "obj");
            }
        }
        /// <summary>
        /// Removes the supplied <see cref="YahooMediaGroup"/> from the current instance's <see cref="Groups"/> collection.
        /// </summary>
        /// <param name="group">The <see cref="YahooMediaGroup"/> to be removed.</param>
        /// <returns><b>true</b> if the <see cref="YahooMediaGroup"/> was removed from the <see cref="Groups"/> collection, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     If the <see cref="Groups"/> collection of the current instance does not contain the specified <see cref="YahooMediaGroup"/>, will return <b>false</b>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="group"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool RemoveGroup(YahooMediaGroup group)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasRemoved = false;

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

            //------------------------------------------------------------
            //	Remove media group from collection
            //------------------------------------------------------------
            if (((Collection <YahooMediaGroup>) this.Groups).Contains(group))
            {
                ((Collection <YahooMediaGroup>) this.Groups).Remove(group);
                wasRemoved = true;
            }

            return(wasRemoved);
        }
        /// <summary>
        /// Removes the supplied <see cref="YahooMediaGroup"/> from the current instance's <see cref="Groups"/> collection.
        /// </summary>
        /// <param name="group">The <see cref="YahooMediaGroup"/> to be removed.</param>
        /// <returns><b>true</b> if the <see cref="YahooMediaGroup"/> was removed from the <see cref="Groups"/> collection, otherwise <b>false</b>.</returns>
        /// <remarks>
        ///     If the <see cref="Groups"/> collection of the current instance does not contain the specified <see cref="YahooMediaGroup"/>, will return <b>false</b>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="group"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool RemoveGroup(YahooMediaGroup group)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasRemoved = false;

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

            //------------------------------------------------------------
            //	Remove media group from collection
            //------------------------------------------------------------
            if (((Collection<YahooMediaGroup>)this.Groups).Contains(group))
            {
                ((Collection<YahooMediaGroup>)this.Groups).Remove(group);
                wasRemoved = true;
            }

            return wasRemoved;
        }
        /// <summary>
        /// Initializes the syndication extension context using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <b>XPathNavigator</b> used to load this <see cref="YahooMediaSyndicationExtensionContext"/>.</param>
        /// <param name="manager">The <see cref="XmlNamespaceManager"/> object used to resolve prefixed syndication extension elements and attributes.</param>
        /// <returns><b>true</b> if the <see cref="YahooMediaSyndicationExtensionContext"/> was able to be initialized using the supplied <paramref name="source"/>; otherwise <b>false</b>.</returns>
        /// <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>
        public bool Load(XPathNavigator source, XmlNamespaceManager manager)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasLoaded  = false;

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

            //------------------------------------------------------------
            //	Attempt to extract syndication extension information
            //------------------------------------------------------------
            if(source.HasChildren)
            {
                XPathNodeIterator contentIterator   = source.Select("media:content", manager);
                XPathNodeIterator groupIterator     = source.Select("media:group", manager);

                if (contentIterator != null && contentIterator.Count > 0)
                {
                    while (contentIterator.MoveNext())
                    {
                        YahooMediaContent content   = new YahooMediaContent();
                        if (content.Load(contentIterator.Current))
                        {
                            this.AddContent(content);
                            wasLoaded   = true;
                        }
                    }
                }

                if (groupIterator != null && groupIterator.Count > 0)
                {
                    while (groupIterator.MoveNext())
                    {
                        YahooMediaGroup group   = new YahooMediaGroup();
                        if (group.Load(groupIterator.Current))
                        {
                            this.AddGroup(group);
                            wasLoaded   = true;
                        }
                    }
                }
            }

            if (YahooMediaUtility.FillCommonObjectEntities(this, source))
            {
                wasLoaded   = true;
            }

            return wasLoaded;
        }
        /// <summary>
        /// Adds the supplied <see cref="YahooMediaGroup"/> to the current instance's <see cref="Groups"/> collection.
        /// </summary>
        /// <param name="group">The <see cref="YahooMediaGroup"/> to be added.</param>
        /// <returns><b>true</b> if the <see cref="YahooMediaGroup"/> was added to the <see cref="Groups"/> collection, otherwise <b>false</b>.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="group"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool AddGroup(YahooMediaGroup group)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            bool wasAdded = false;

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

            //------------------------------------------------------------
            //	Add media group to collection
            //------------------------------------------------------------
            ((Collection<YahooMediaGroup>)this.Groups).Add(group);
            wasAdded = true;

            return wasAdded;
        }