コード例 #1
0
ファイル: AtomId.cs プロジェクト: gauravbhavsar/Argotic
        //============================================================
        //	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
            //------------------------------------------------------------
            AtomId value = obj as AtomId;

            if (value != null)
            {
                int result = Uri.Compare(this.Uri, value.Uri, UriComponents.AbsoluteUri, UriFormat.Unescaped, StringComparison.Ordinal);

                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");
            }
        }
コード例 #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);
            }
            AtomLink value = obj as AtomLink;

            if (value != null)
            {
                int result = this.Length.CompareTo(value.Length);
                result = result | String.Compare(this.ContentType, value.ContentType, StringComparison.OrdinalIgnoreCase);
                result = result | String.Compare(this.Relation, value.Relation, StringComparison.OrdinalIgnoreCase);

                string sourceLanguageName = this.ContentLanguage != null ? this.ContentLanguage.Name : String.Empty;
                string targetLanguageName = value.ContentLanguage != null ? value.ContentLanguage.Name : String.Empty;
                result = result | String.Compare(sourceLanguageName, targetLanguageName, StringComparison.OrdinalIgnoreCase);

                result = result | String.Compare(this.Title, value.Title, StringComparison.OrdinalIgnoreCase);
                result = result | Uri.Compare(this.Uri, value.Uri, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase);

                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");
            }
        }
コード例 #3
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
            //------------------------------------------------------------
            AtomTextConstruct value = obj as AtomTextConstruct;

            if (value != null)
            {
                int result = String.Compare(this.Content, value.Content, StringComparison.OrdinalIgnoreCase);
                result = result | this.TextType.CompareTo(value.TextType);

                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");
            }
        }
コード例 #4
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);
            }
            AtomLogo value = obj as AtomLogo;

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

                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");
            }
        }
コード例 #5
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);
            }
            AtomTextConstruct value = obj as AtomTextConstruct;

            if (value != null)
            {
                int result = String.Compare(this.Content, value.Content, StringComparison.OrdinalIgnoreCase);
                result = result | this.TextType.CompareTo(value.TextType);

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