Exemplo n.º 1
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);
            }
            AtomSource value = obj as AtomSource;

            if (value != null)
            {
                int result = AtomFeed.CompareSequence(this.Authors, value.Authors);
                result = result | AtomFeed.CompareSequence(this.Categories, value.Categories);
                result = result | AtomFeed.CompareSequence(this.Contributors, value.Contributors);

                if (this.Generator != null)
                {
                    result = result | this.Generator.CompareTo(value.Generator);
                }
                else if (value.Generator != null)
                {
                    result = result | -1;
                }

                if (this.Icon != null)
                {
                    result = result | this.Icon.CompareTo(value.Icon);
                }
                else if (value.Icon != null)
                {
                    result = result | -1;
                }

                if (this.Id != null)
                {
                    result = result | this.Id.CompareTo(value.Id);
                }
                else if (value.Id != null)
                {
                    result = result | -1;
                }

                result = result | AtomFeed.CompareSequence(this.Links, value.Links);

                if (this.Logo != null)
                {
                    result = result | this.Logo.CompareTo(value.Logo);
                }
                else if (value.Logo != null)
                {
                    result = result | -1;
                }

                if (this.Rights != null)
                {
                    result = result | this.Rights.CompareTo(value.Rights);
                }
                else if (value.Rights != null)
                {
                    result = result | -1;
                }

                if (this.Subtitle != null)
                {
                    result = result | this.Subtitle.CompareTo(value.Subtitle);
                }
                else if (value.Subtitle != null)
                {
                    result = result | -1;
                }

                if (this.Title != null)
                {
                    result = result | this.Title.CompareTo(value.Title);
                }
                else if (value.Title != null)
                {
                    result = result | -1;
                }

                result = result | this.UpdatedOn.CompareTo(value.UpdatedOn);

                result = result | AtomUtility.CompareCommonObjectAttributes(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");
            }
        }