Ejemplo n.º 1
0
        /// <summary>
        /// Gets the differences between this item and another of the same type
        /// </summary>
        /// <param name="other">Another item of the same type</param>
        /// <param name="allDifferences">if set to <c>true</c> collects all differences,
        /// otherwise only the first difference is collected.</param>
        /// <returns>
        /// A Difference if there are differences between the items, otherwise null
        /// </returns>
        public override Difference GetDifferences(Item other, bool allDifferences)
        {
            FulltextColumn otherColumn = other as FulltextColumn;

            if (otherColumn == null)
            {
                return(new Difference(DifferenceType.Created, Name));
            }

            Difference difference = new Difference(DifferenceType.Modified, Name);

            if (Name != otherColumn.Name)
            {
                difference.AddMessage("Name", otherColumn.Name, Name);
                if (!allDifferences)
                {
                    return(difference);
                }
            }
            if (Language != otherColumn.Language)
            {
                difference.AddMessage("Language", otherColumn.Language, Language);
                if (!allDifferences)
                {
                    return(difference);
                }
            }

            return(difference.Messages.Count > 0 ? difference : null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
        /// </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. The return value has these meanings:
        /// Value
        /// Meaning
        /// Less than zero
        /// This instance is less than <paramref name="obj"/>.
        /// Zero
        /// This instance is equal to <paramref name="obj"/>.
        /// Greater than zero
        /// This instance is greater than <paramref name="obj"/>.
        /// </returns>
        /// <exception cref="T:System.ArgumentException">
        ///     <paramref name="obj"/> is not the same type as this instance.
        /// </exception>
        public int CompareTo(object obj)
        {
            FulltextColumn other = obj as FulltextColumn;

            if (other == null)
            {
                throw new Exception("Incomparable objects");
            }

            return(Name.ToString().CompareTo(other.Name.ToString()));
        }