Esempio n. 1
0
        /// <summary>
        /// Compares the current instance with another <see cref="System.Object"/> and returns an integer that indicates
        /// whether the current instance precedes, follows, or occurs in the same position in the sort
        /// order as the specified <see cref="System.Object"/>.
        /// </summary>
        /// <param name="obj">An object that evalutes to a <see cref="Irc.User"/>.</param>
        /// <returns>An integer that indicates whether the current instance precedoes, follow or occurs
        /// in the same position in the sort order as the specified <see cref="Irc.User"/></returns>
        /// <exception cref="System.ArgumentException">Thrown if obj is not a <see cref="Irc.User"/>.</exception>
        public virtual int CompareTo(object obj)
        {
            if (!(obj is User))
            {
                throw new ArgumentException("Object must be of type Irc.User.");
            }


            /**
             * If objects are equal: return 0
             * If this object occurs before the parameter: return less than 0
             * If this object occurs after the parameter: return greater than 0
             *
             */

            int retVal = 1;

            if (obj != null)
            {
                User other = (User)obj;
                retVal = Nickname.CompareTo(other.Nickname);
            }

            return(retVal);
        }
Esempio n. 2
0
        /// <summary>
        /// Compares the current instance with another <see cref="System.Object"/> and returns an integer that indicates
        /// whether the current instance precedes, follows, or occurs in the same position in the sort
        /// order as the specified <see cref="System.Object"/>.
        /// </summary>
        /// <param name="obj">An object that evalutes to a <see cref="Irc.ChannelUser"/>.</param>
        /// <returns>An integer that indicates whether the current instance precedes, follows or occurs
        /// in the same position in the sort order as the specified <see cref="Irc.ChannelUser"/></returns>
        /// <exception cref="System.ArgumentException">Thrown if obj is not a <see cref="Irc.ChannelUser"/>.</exception>
        public override int CompareTo(object obj)
        {
            if (!(obj is ChannelUser))
            {
                throw new ArgumentException("Object must be of type Irc.ChannelUser.");
            }


            /**
             * If objects are equal: return 0
             * If this object occurs before the parameter: return less than 0
             * If this object occurs after the parameter: return greater than 0
             *
             */

            int retVal = 1;

            if (obj != null)
            {
                ChannelUser other = (ChannelUser)obj;

                //compare channel status first
                retVal = this.ChannelStatus.CompareTo(other.ChannelStatus) * -1;

                //if channel status is equal, sort by name
                if (retVal == 0)
                {
                    retVal = Nickname.CompareTo(other.Nickname);
                }
            }

            return(retVal);
        }
Esempio n. 3
0
 public int CompareTo(Player other)
 {
     return(Nickname.CompareTo(other.Nickname));
 }