protected static bool EqualOperator(ValueObject left, ValueObject right)
 {
     if (ReferenceEquals(left, null) ^ ReferenceEquals(right, null))
     {
         return(false);
     }
     return(ReferenceEquals(left, null) || left.Equals(right));
 }
Beispiel #2
0
 /// <summary>
 /// 相等
 /// </summary>
 /// <param name="left">值对象,派生自ValueObject</param>
 /// <param name="right">值对象,派生自ValueObject</param>
 /// <returns>是否相等</returns>
 protected static bool EqualOperator(ValueObject left, ValueObject right)
 {
     if (left is null ^ right is null)
     {
         return(false);
     }
     //到这里要么两个都为Null,要么都不为Null
     return(left is null || left.Equals(right));
 }
Beispiel #3
0
        /// <summary>
        /// 两个值对象是否相等
        /// </summary>
        /// <param name="left">左边值对象</param>
        /// <param name="right">右边值对象</param>
        /// <returns>是否相等</returns>
        protected static bool EqualOperator(ValueObject left, ValueObject right)
        {
            //针对整型类型和 bool 预定义了二元 ^ 运算符。
            //对于整型类型,^ 会计算其操作数的按位异或。
            //对于 bool 操作数,^ 计算其操作数的逻辑异或;即,当且仅当其一个操作数为 true 时,结果才为 true
            if (ReferenceEquals(left, null) ^ ReferenceEquals(right, null))
            {
                return(false);
            }

            return(ReferenceEquals(left, null) || left.Equals(right));
        }