public void GetCompiledExpression_ExpressionsEqual_SameDelegate()
        {
            Expression <Func <Person, string> > expressionZero = person => person.Name;
            Expression <Func <Person, string> > expressionOne  = person => person.Name;

            Func <Person, string> cachedZero = CompiledExpressionCache.CachedCompile(expressionZero);
            Func <Person, string> cachedOne  = CompiledExpressionCache.CachedCompile(expressionOne);

            Assert.AreEqual(cachedZero, cachedOne);
        }
예제 #2
0
        private void AddExpressionToCaches(WfExpression wfExpr)
        {
            var argToPopulate = wfExpr.ArgumentToPopulate;

            if (argToPopulate != null)
            {
                _expressionArgumentCache.TryAdd(wfExpr.Id, argToPopulate);

                _expressionArgumentTypeCache.TryAdd(argToPopulate.Id, CalcExpressionType(argToPopulate));

                var expression = CompileExpression(wfExpr);

                CompiledExpressionCache.TryAdd(wfExpr.Id, expression);
            }
        }