當前位置: 首頁>>代碼示例>>C#>>正文


C# Expression.Reduce方法代碼示例

本文整理匯總了C#中System.Linq.Expressions.Expression.Reduce方法的典型用法代碼示例。如果您正苦於以下問題:C# Expression.Reduce方法的具體用法?C# Expression.Reduce怎麽用?C# Expression.Reduce使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Linq.Expressions.Expression的用法示例。


在下文中一共展示了Expression.Reduce方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CompileExtensionExpression

        private void CompileExtensionExpression(Expression expr) {
            var instructionProvider = expr as IInstructionProvider;
            if (instructionProvider != null) {
                AddInstruction(instructionProvider.GetInstruction(this));
                return;
            }

            var node = expr as Microsoft.Scripting.Ast.SymbolConstantExpression;
            if (node != null) {
                PushConstant(node.Value);
                return;
            }

            if (expr.CanReduce) {
                Compile(expr.Reduce());
            } else {
                throw new System.NotImplementedException();
            }
        }
開發者ID:bclubb,項目名稱:ironruby,代碼行數:19,代碼來源:LightCompiler.cs

示例2: CompileExtensionExpression

 private void CompileExtensionExpression(Expression expr)
 {
     IInstructionProvider provider = expr as IInstructionProvider;
     if (provider != null)
     {
         provider.AddInstructions(this);
     }
     else
     {
         if (!expr.CanReduce)
         {
             throw new NotImplementedException();
         }
         this.Compile(expr.Reduce());
     }
 }
開發者ID:nickchal,項目名稱:pash,代碼行數:16,代碼來源:LightCompiler.cs

示例3: Visit

 public override Expression Visit(Expression node)
     => node != null
        && node.CanReduce
         ? Visit(node.Reduce())
         : base.Visit(node);
開發者ID:rbenhassine2,項目名稱:EntityFramework,代碼行數:5,代碼來源:ReducingExpressionVisitor.cs

示例4: CompileImpl

        private object CompileImpl(Expression expression, CompilerState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }

            state.RawReturnType = expression.Type;

            while (expression.CanReduce)
            {
                expression = expression.Reduce();
            }

            LambdaExpression lambda;
            var paramTypes = state.CompileToAction ? new Type[state.Arguments.Count] : new Type[state.Arguments.Count + 1];
            for (var i = 0; i < state.Arguments.Count; i++)
            {
                paramTypes[i] = state.Arguments[i].Type;
            }

            if (state.CompileToAction)
            {
                lambda = Expression.Lambda(Expression.GetActionType(paramTypes), expression, state.Arguments);
            }
            else
            {
                var returnType = state.ReturnType ?? state.RawReturnType;
                paramTypes[paramTypes.Length - 1] = returnType;

                expression = ExpressionTreeExtensions.AdjustReturnType(null, expression, returnType);
                lambda = Expression.Lambda(expression, state.Arguments);

                if (!ReferenceEquals(returnType, lambda.ReturnType))
                {
                    throw new CompilationException(string.Format("Expected return type: {0}. Real return type: {1}", returnType.FullName, lambda.ReturnType.FullName));
                }
            }

            if (lambda.Parameters.Count != state.Arguments.Count)
            {
                throw new CompilationException(string.Format("Expected number of arguments: {0}. Real number: {1}", state.Arguments.Count, lambda.Parameters.Count));
            }

            for (var i = 0; i < lambda.Parameters.Count; i++)
            {
                if (!ReferenceEquals(lambda.Parameters[i].Type, state.Arguments[i].Type))
                {
                    throw new CompilationException(
                        string.Format("Expected type of argument {0}: {1}. Real type: {2}", i, state.Arguments[i].Type.FullName, lambda.Parameters[i].Type.FullName));
                }
            }

            return lambda.Compile();
        }
開發者ID:adrobyazko-softheme,項目名稱:PQL,代碼行數:55,代碼來源:ExpressionEvaluatorRuntime(Compiler).cs

示例5: VisitReducible

 public Expression VisitReducible(Expression node)
 {
     Debug.Assert(node.CanReduce);
     return Visit(node.Reduce());
 }
開發者ID:runerei,項目名稱:Cartographer,代碼行數:5,代碼來源:ReduceExpressionVisitor.cs


注:本文中的System.Linq.Expressions.Expression.Reduce方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。