示例#1
0
        /// <summary>
        /// Base equality operator.
        /// </summary>
        /// <param name="other">Other.</param>
        /// <returns>Is equal.</returns>
        protected virtual bool Equals(AbstractMessage other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (!IsTransient(this) &&
                !IsTransient(other) &&
                Id.Equals(other.Id, StringComparison.InvariantCultureIgnoreCase))
            {
                var otherType = other.GetType();
                var thisType  = GetType();
                return(thisType.IsAssignableFrom(otherType) ||
                       otherType.IsAssignableFrom(thisType));
            }

            return(false);
        }
示例#2
0
 private static bool IsTransient(AbstractMessage obj)
 {
     return(obj != null && string.IsNullOrWhiteSpace(obj.Id));
 }