//============================================================ // 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"); } }
/// <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> /// 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); } YahooMediaContent value = obj as YahooMediaContent; if (value != null) { int result = this.Bitrate.CompareTo(value.Bitrate); result = result | this.Channels.CompareTo(value.Channels); result = result | String.Compare(this.ContentType, value.ContentType, StringComparison.OrdinalIgnoreCase); result = result | this.Duration.CompareTo(value.Duration); result = result | this.Expression.CompareTo(value.Expression); result = result | this.FileSize.CompareTo(value.FileSize); result = result | this.FrameRate.CompareTo(value.FrameRate); result = result | this.Height.CompareTo(value.Height); result = result | this.IsDefault.CompareTo(value.IsDefault); string sourceLanguageName = this.Language != null ? this.Language.Name : String.Empty; string targetLanguageName = value.Language != null ? value.Language.Name : String.Empty; result = result | String.Compare(sourceLanguageName, targetLanguageName, StringComparison.OrdinalIgnoreCase); result = result | this.Medium.CompareTo(value.Medium); result = result | this.SamplingRate.CompareTo(value.SamplingRate); result = result | Uri.Compare(this.Url, value.Url, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase); result = result | this.Width.CompareTo(value.Width); 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"); } }