Пример #1
0
        internal static bool Equals(LambdaExpression?x, LambdaExpression?y)
        {
            if (ReferenceEquals(x, y))
            {
                return(true);
            }

            if (x is null || y is null)
            {
                return(false);
            }

            var xMember = x.GetRootProperty();
            var yMember = y.GetRootProperty();

            while (xMember != null &&
                   yMember != null)
            {
                if (!MemberExpressionComparer.Equals(xMember, yMember))
                {
                    return(false);
                }

                xMember = xMember.GetPreviousProperty();
                yMember = yMember.GetPreviousProperty();
            }

            return(xMember is null && yMember is null &&
                   x.GetSourceType() == y.GetSourceType());
        }
Пример #2
0
        private static int GetHashCode(LambdaExpression obj)
        {
            var member = obj.GetRootProperty();

            unchecked
            {
                var hash = 19;
                do
                {
                    hash   = (hash * 397) ^ MemberExpressionComparer.GetHashCode(member);
                    member = member.GetPreviousProperty();
                }while (member != null);
                return((hash * 397) ^ obj.GetSourceType().GetHashCode());
            }
        }
Пример #3
0
        internal static bool Equals(LambdaExpression x, LambdaExpression y)
        {
            var xMember = x.GetRootProperty();
            var yMember = y.GetRootProperty();

            while (xMember != null && yMember != null)
            {
                if (!MemberExpressionComparer.Equals(xMember, yMember))
                {
                    return(false);
                }

                xMember = xMember.GetPreviousProperty();
                yMember = yMember.GetPreviousProperty();
            }

            return(xMember == null && yMember == null &&
                   x.GetSourceType() == y.GetSourceType());
        }