Exemple #1
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (!obj.GetType().Equals(GetType()))
            {
                return(false);
            }

            EntityBaseGenericId <TID> other = (EntityBaseGenericId <TID>)obj;

            if (!base.Equals(obj))
            {
                return(false);
            }
            if (this.Id == null || !this.Id.Equals(other.Id))
            {
                return(false);
            }
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Compares to.
        /// </summary>
        /// <param name="o">The other.</param>
        /// <returns></returns>
        public override int CompareTo(EntityBaseWithoutId o)
        {
            if (o == null)
            {
                ThrowHelper.ThrowArgumentNullException("o");
            }
            if (!(o is EntityBaseGenericId <TID>))
            {
                ThrowHelper.ThrowArgumentException("o");
            }

            EntityBaseGenericId <TID> obj = (EntityBaseGenericId <TID>)o;
            int result = 0;

            if (this.Id == null)
            {
                result = this.EntityCreationTime.CompareTo(obj.EntityCreationTime);
            }
            else
            {
                result = this.Id.CompareTo(obj.Id);
            }
            return(result); // default is equals. This provides the functionality as keep the original order of the treesets
        }