//============================================================
        //	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
            //------------------------------------------------------------
            SyndicationResourceLoadSettings value = obj as SyndicationResourceLoadSettings;

            if (value != null)
            {
                int result = String.Compare(this.CharacterEncoding.WebName, value.CharacterEncoding.WebName, StringComparison.OrdinalIgnoreCase);
                result = result | this.RetrievalLimit.CompareTo(value.RetrievalLimit);
                result = result | this.Timeout.CompareTo(value.Timeout);
                result = result | this.AutoDetectExtensions.CompareTo(value.AutoDetectExtensions);
                result = result | ComparisonUtility.CompareSequence(this.SupportedExtensions, value.SupportedExtensions);

                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");
            }
        }
示例#2
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);
            }

            SyndicationResourceMetadata value = obj as SyndicationResourceMetadata;

            if (value != null)
            {
                int result = this.Format.CompareTo(value.Format);

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

                if (this.Namespaces != null && value.Namespaces != null)
                {
                    result = result | ComparisonUtility.CompareSequence(this.Namespaces, value.Namespaces, StringComparison.Ordinal);
                }
                else if (this.Namespaces != null && value.Namespaces == null)
                {
                    result = result | 1;
                }
                else if (this.Namespaces == null && value.Namespaces != null)
                {
                    result = result | -1;
                }

                if (this.Resource != null && value.Resource != null)
                {
                    result = result | String.Compare(this.Resource.OuterXml, value.Resource.OuterXml, StringComparison.OrdinalIgnoreCase);
                }
                else if (this.Resource != null && value.Resource == null)
                {
                    result = result | 1;
                }
                else if (this.Resource == null && value.Resource != null)
                {
                    result = result | -1;
                }

                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);
            }

            SyndicationResourceSaveSettings value = obj as SyndicationResourceSaveSettings;

            if (value != null)
            {
                int result = String.Compare(this.CharacterEncoding.WebName, value.CharacterEncoding.WebName, StringComparison.OrdinalIgnoreCase);
                result = result | this.MinimizeOutputSize.CompareTo(value.MinimizeOutputSize);
                result = result | ComparisonUtility.CompareSequence(this.SupportedExtensions, value.SupportedExtensions);
                result = result | this.AutoDetectExtensions.CompareTo(value.AutoDetectExtensions);

                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");
            }
        }