Exemple #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
            //------------------------------------------------------------
            YahooMediaPlayer value = obj as YahooMediaPlayer;

            if (value != null)
            {
                int result = this.Height.CompareTo(value.Height);
                result = result | Uri.Compare(this.Url, value.Url, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase);
                result = result | this.Width.CompareTo(value.Width);

                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>
        /// 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);
            }
            YahooMediaPlayer value = obj as YahooMediaPlayer;

            if (value != null)
            {
                int result = this.Height.CompareTo(value.Height);
                result = result | Uri.Compare(this.Url, value.Url, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase);
                result = result | this.Width.CompareTo(value.Width);

                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");
            }
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="YahooMediaContent"/> class using the supplied <see cref="YahooMediaPlayer"/>.
        /// </summary>
        /// <param name="player">A <see cref="YahooMediaPlayer"/> that represents a web browser media player console this media object can be accessed through.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="player"/> is a null reference (Nothing in Visual Basic).</exception>
        public YahooMediaContent(YahooMediaPlayer player)
        {
            Guard.ArgumentNotNull(player, "player");

            this.Player = player;
        }
Exemple #4
0
        /// <summary>
        /// Modifies the classes 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 FillCommonObjectEntityClasses(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)
            {
                XPathNavigator titleNavigator       = source.SelectSingleNode("media:title", manager);
                XPathNavigator descriptionNavigator = source.SelectSingleNode("media:description", manager);
                XPathNavigator copyrightNavigator   = source.SelectSingleNode("media:copyright", manager);
                XPathNavigator playerNavigator      = source.SelectSingleNode("media:player", manager);
                XPathNavigator keywordNavigator     = source.SelectSingleNode("media:keywords", manager);

                if (titleNavigator != null)
                {
                    YahooMediaTextConstruct title   = new YahooMediaTextConstruct();
                    if (title.Load(titleNavigator))
                    {
                        target.Title    = title;
                        wasLoaded       = true;
                    }
                }

                if (descriptionNavigator != null)
                {
                    YahooMediaTextConstruct description = new YahooMediaTextConstruct();
                    if (description.Load(descriptionNavigator))
                    {
                        target.Description  = description;
                        wasLoaded           = true;
                    }
                }

                if (copyrightNavigator != null)
                {
                    YahooMediaCopyright copyright = new YahooMediaCopyright();
                    if (copyright.Load(copyrightNavigator))
                    {
                        target.Copyright    = copyright;
                        wasLoaded           = true;
                    }
                }

                if (playerNavigator != null)
                {
                    YahooMediaPlayer player = new YahooMediaPlayer();
                    if (player.Load(playerNavigator))
                    {
                        target.Player   = player;
                        wasLoaded       = true;
                    }
                }

                if (keywordNavigator != null && !String.IsNullOrEmpty(keywordNavigator.Value))
                {
                    if (keywordNavigator.Value.Contains(","))
                    {
                        string[] keywords = keywordNavigator.Value.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        if (keywords.Length > 0)
                        {
                            foreach (string keyword in keywords)
                            {
                                target.Keywords.Add(keyword);
                            }
                            wasLoaded = true;
                        }
                    }
                    else
                    {
                        target.Keywords.Add(keywordNavigator.Value.Trim());
                        wasLoaded   = true;
                    }
                }
            }

            return wasLoaded;
        }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="YahooMediaContent"/> class using the supplied <see cref="YahooMediaPlayer"/>.
        /// </summary>
        /// <param name="player">A <see cref="YahooMediaPlayer"/> that represents a web browser media player console this media object can be accessed through.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="player"/> is a null reference (Nothing in Visual Basic).</exception>
        public YahooMediaContent(YahooMediaPlayer player)
        {
            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(player, "player");

            this.Player = player;
        }
Exemple #6
0
        /// <summary>
        /// Modifies the classes 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 FillCommonObjectEntityClasses(IYahooMediaCommonObjectEntities target, XPathNavigator source, XmlNamespaceManager manager)
        {
            bool wasLoaded = false;

            Guard.ArgumentNotNull(target, "target");
            Guard.ArgumentNotNull(source, "source");
            Guard.ArgumentNotNull(manager, "manager");
            if (source.HasChildren)
            {
                XPathNavigator titleNavigator       = source.SelectSingleNode("media:title", manager);
                XPathNavigator descriptionNavigator = source.SelectSingleNode("media:description", manager);
                XPathNavigator copyrightNavigator   = source.SelectSingleNode("media:copyright", manager);
                XPathNavigator playerNavigator      = source.SelectSingleNode("media:player", manager);
                XPathNavigator keywordNavigator     = source.SelectSingleNode("media:keywords", manager);

                if (titleNavigator != null)
                {
                    YahooMediaTextConstruct title = new YahooMediaTextConstruct();
                    if (title.Load(titleNavigator))
                    {
                        target.Title = title;
                        wasLoaded    = true;
                    }
                }

                if (descriptionNavigator != null)
                {
                    YahooMediaTextConstruct description = new YahooMediaTextConstruct();
                    if (description.Load(descriptionNavigator))
                    {
                        target.Description = description;
                        wasLoaded          = true;
                    }
                }

                if (copyrightNavigator != null)
                {
                    YahooMediaCopyright copyright = new YahooMediaCopyright();
                    if (copyright.Load(copyrightNavigator))
                    {
                        target.Copyright = copyright;
                        wasLoaded        = true;
                    }
                }

                if (playerNavigator != null)
                {
                    YahooMediaPlayer player = new YahooMediaPlayer();
                    if (player.Load(playerNavigator))
                    {
                        target.Player = player;
                        wasLoaded     = true;
                    }
                }

                if (keywordNavigator != null && !String.IsNullOrEmpty(keywordNavigator.Value))
                {
                    if (keywordNavigator.Value.Contains(","))
                    {
                        string[] keywords = keywordNavigator.Value.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        if (keywords.Length > 0)
                        {
                            foreach (string keyword in keywords)
                            {
                                target.Keywords.Add(keyword);
                            }
                            wasLoaded = true;
                        }
                    }
                    else
                    {
                        target.Keywords.Add(keywordNavigator.Value.Trim());
                        wasLoaded = true;
                    }
                }
            }

            return(wasLoaded);
        }