Пример #1
0
        /// <summary>
        /// Compares this trait with another one.
        /// The <see cref="Context"/> is the primary key (see <see cref="CKTraitContext.CompareTo"/>), then comes
        /// the number of traits (more traits is greater) and then comes the string representation of the trait in
        /// reverse lexical order (<see cref="StringComparer.Ordinal"/>): "A" is greater than "B".
        /// </summary>
        /// <param name="other">The trait to compare to.</param>
        /// <returns>A negative, zero or positive value.</returns>
        public int CompareTo(CKTrait other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other");
            }
            if (ReferenceEquals(this, other))
            {
                return(0);
            }
            if (_context != other._context)
            {
                return(_context.CompareTo(other._context));
            }
            int cmp = _traits.Count - other.AtomicTraits.Count;

            if (cmp == 0)
            {
                cmp = StringComparer.Ordinal.Compare(other._trait, _trait);
            }
            return(cmp);
        }
Пример #2
0
        /// <summary>
        /// Compares this tag with another one.
        /// The <see cref="Context"/> is the primary key (see <see cref="CKTraitContext.CompareTo"/>), then comes
        /// the number of tags (more tags is greater) and then comes the string representation of the tag in
        /// reverse lexical order (<see cref="StringComparer.Ordinal"/>): "A" is greater than "B".
        /// </summary>
        /// <param name="other">The tag to compare to. Can be null: any trait is greater than null.</param>
        /// <returns>A negative, zero or positive value.</returns>
        public int CompareTo(CKTrait other)
        {
            if (other == null)
            {
                return(1);
            }
            if (ReferenceEquals(this, other))
            {
                return(0);
            }
            int cmp = _context.CompareTo(other._context);

            if (cmp == 0)
            {
                cmp = _tags.Count - other.AtomicTraits.Count;
                if (cmp == 0)
                {
                    cmp = StringComparer.Ordinal.Compare(other._tag, _tag);
                }
            }
            return(cmp);
        }