コード例 #1
0
        /// <summary>
        /// Compares the collections for objects that implement the <see cref="IYahooMediaCommonObjectEntities"/> interface.
        /// </summary>
        /// <param name="source">A object that implements the <see cref="IYahooMediaCommonObjectEntities"/> interface to be compared.</param>
        /// <param name="target">A object that implements the <see cref="IYahooMediaCommonObjectEntities"/> to compare with the <paramref name="source"/>.</param>
        /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns>
        private static int CompareCommonObjectEntityCollections(IYahooMediaCommonObjectEntities source, IYahooMediaCommonObjectEntities target)
        {
            int result = 0;

            if (source == null && target == null)
            {
                return(0);
            }
            else if (source != null && target == null)
            {
                return(1);
            }
            else if (source == null && target != null)
            {
                return(-1);
            }
            result = result | YahooMediaUtility.CompareSequence(source.Categories, target.Categories);
            result = result | YahooMediaUtility.CompareSequence(source.Credits, target.Credits);
            result = result | YahooMediaUtility.CompareSequence(source.Hashes, target.Hashes);
            result = result | ComparisonUtility.CompareSequence(source.Keywords, target.Keywords, StringComparison.OrdinalIgnoreCase);
            result = result | YahooMediaUtility.CompareSequence(source.Ratings, target.Ratings);
            result = result | YahooMediaUtility.CompareSequence(source.Restrictions, target.Restrictions);
            result = result | YahooMediaUtility.CompareSequence(source.TextSeries, target.TextSeries);
            result = result | YahooMediaUtility.CompareSequence(source.Thumbnails, target.Thumbnails);

            return(result);
        }
コード例 #2
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
            //------------------------------------------------------------
            YahooMediaSyndicationExtension value = obj as YahooMediaSyndicationExtension;

            if (value != null)
            {
                int result = YahooMediaUtility.CompareSequence((Collection <YahooMediaContent>) this.Context.Contents, (Collection <YahooMediaContent>)value.Context.Contents);
                result = result | YahooMediaUtility.CompareSequence((Collection <YahooMediaGroup>) this.Context.Groups, (Collection <YahooMediaGroup>)value.Context.Groups);

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

                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");
            }
        }
コード例 #3
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");
            }
        }