public ExpressionWrapper(Expression expression, bool strictly) { this.Expression = expression; this.strictly = strictly; hashCode = new Lazy <int>(() => ExpressionHashCalculator.CalcHashCode(expression, strictly), LazyThreadSafetyMode.PublicationOnly); }
public void Test3() { Expression <Func <TestClassA, string> > exp1 = a => a.ArrayB.First(b => b.S.Length > 0).S; Expression <Func <TestClassA, string> > exp2 = aa => aa.ArrayB.First(bb => bb.S.Length > 0).S; var hash1 = ExpressionHashCalculator.CalcHashCode(exp1, true); var hash2 = ExpressionHashCalculator.CalcHashCode(exp2, true); Assert.AreNotEqual(hash1, hash2); hash1 = ExpressionHashCalculator.CalcHashCode(exp1, false); hash2 = ExpressionHashCalculator.CalcHashCode(exp2, false); Assert.AreEqual(hash1, hash2); }
public void Test2() { Expression <Func <TestClassA, string> > exp1 = a => a.S; Expression <Func <TestClassB, string> > exp2 = a => a.S; var hash1 = ExpressionHashCalculator.CalcHashCode(exp1, true); var hash2 = ExpressionHashCalculator.CalcHashCode(exp2, true); Assert.AreNotEqual(hash1, hash2); hash1 = ExpressionHashCalculator.CalcHashCode(exp1, false); hash2 = ExpressionHashCalculator.CalcHashCode(exp2, false); Assert.AreNotEqual(hash1, hash2); }
public override int GetHashCode() { return(ExpressionHashCalculator.CalcHashCode(Expression, strictly)); }