• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Expressions.InvocationExpression类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Linq.Expressions.InvocationExpression的典型用法代码示例。如果您正苦于以下问题:C# InvocationExpression类的具体用法?C# InvocationExpression怎么用?C# InvocationExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



InvocationExpression类属于System.Linq.Expressions命名空间,在下文中一共展示了InvocationExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: VisitInvocation

 protected override Expression VisitInvocation(InvocationExpression iv)
 {
     if (iv.Expression is LambdaExpression)
         return Visit(ExpressionReplacer.Replace(iv));
     else
         return base.VisitInvocation(iv); //Just calling a delegate in the projector
 }
开发者ID:signumsoftware,项目名称:framework,代码行数:7,代码来源:ExpressionCleaner.cs


示例2: UpdateInvocation

 protected InvocationExpression UpdateInvocation(InvocationExpression iv, Expression expression, IEnumerable<Expression> args)
 {
     if (args != iv.Arguments || expression != iv.Expression) {
         return Expression.Invoke(expression, args);
     }
     return iv;
 }
开发者ID:kpfaulkner,项目名称:Linq-To-Search,代码行数:7,代码来源:ExpressionVisitor.cs


示例3: VisitInvocation

        /// <summary>
        /// Flatten calls to Invoke so that Entity Framework can understand it. Calls to Invoke are generated
        /// by PredicateBuilder.
        /// </summary>
        protected override Expression VisitInvocation(InvocationExpression iv)
        {
            Expression target = iv.Expression;
            if (target is MemberExpression) target = TransformExpr ((MemberExpression)target);
            if (target is ConstantExpression) target = ((ConstantExpression)target).Value as Expression;

            LambdaExpression lambda = (LambdaExpression)target;

            Dictionary<ParameterExpression, Expression> replaceVars;
            if (_replaceVars == null)
                replaceVars = new Dictionary<ParameterExpression, Expression> ();
            else
                replaceVars = new Dictionary<ParameterExpression, Expression> (_replaceVars);

            try
            {
                for (int i = 0; i < lambda.Parameters.Count; i++)
                    replaceVars.Add (lambda.Parameters[i], iv.Arguments[i]);
            }
            catch (ArgumentException ex)
            {
                throw new InvalidOperationException ("Invoke cannot be called recursively - try using a temporary variable.", ex);
            }

            return new ExpressionExpander (replaceVars).Visit (lambda.Body);
        }
开发者ID:kaleylab,项目名称:KaleyLab,代码行数:30,代码来源:ExpressionExpander.cs


示例4: ParseInvocation

        private ExpressionNode ParseInvocation(InvocationExpression ie)
        {
            var args = new List<LiteralNode>();
            foreach(var arg in ie.Arguments)
            {
                if (arg is ParameterExpression)
                {
                    var name = ((ParameterExpression)arg).Name;
                    args.Add(new VariableNode(name));
                }
                else if (arg is ConstantExpression)
                {
                    var token = (String)((ConstantExpression)arg).Value;
                    args.Add(new ConstantNode(token));
                }
                else
                {
                    return Unsupported(arg);
                }
            }

            if (ie.Expression is MemberExpression)
            {
                var term = GetTermFromMemberExpression((MemberExpression)ie.Expression);
                return new TermNode(term, args.ToArray());
            }

            return Unsupported(ie);
        }
开发者ID:xeno-by,项目名称:rapt,代码行数:29,代码来源:LinqAstParser.cs


示例5: AssertInvokeIsOptimized

        private static void AssertInvokeIsOptimized(InvocationExpression expr, Expression expression, IReadOnlyList<Expression> args)
        {
            var n = args.Count;

            var updated = Update(expr);
            var visited = Visit(expr);

            foreach (var node in new[] { expr, updated, visited })
            {
                Assert.Same(expression, node.Expression);

                AssertInvocation(n, node);

                var argProvider = node as IArgumentProvider;
                Assert.NotNull(argProvider);

                Assert.Equal(n, argProvider.ArgumentCount);

                if (node != visited) // our visitor clones argument nodes
                {
                    for (var i = 0; i < n; i++)
                    {
                        Assert.Same(args[i], argProvider.GetArgument(i));
                        Assert.Same(args[i], node.Arguments[i]);
                    }
                }
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:28,代码来源:InvokeFactoryTests.cs


示例6: DoVisit

 private void DoVisit(InvocationExpression invocation)
 {
     foreach (var arg in invocation.Arguments)
     {
         Visit(arg);
     }
     Visit(invocation.Expression);
 }
开发者ID:Xamarui,项目名称:IdentityServer3.Contrib.ElasticSearchEventService,代码行数:8,代码来源:LambdaString.cs


示例7: VisitInvocation

 protected override Expression VisitInvocation(InvocationExpression node)
 {
     if (typeof(Delegate).IsAssignableFrom(node.Expression.Type) || IsObservableFuncType(node.Expression.Type, node.Arguments.Count))
     {
         return VisitMethodCall(Expression.Call(node.Expression, node.Expression.Type.GetMethod("Invoke"), node.Arguments));
     }
     throw new InvalidOperationException("Unclear what to invoke.");
 }
开发者ID:FrederikP,项目名称:NMF,代码行数:8,代码来源:ObservableExpressionBinder.Reflection.cs


示例8: UpdateInvocation

 protected static InvocationExpression UpdateInvocation(InvocationExpression node, Expression expression,
                                                        IEnumerable<Expression> args)
 {
     if (node.Arguments != args || node.Expression != expression)
     {
         return Expression.Invoke(expression, args);
     }
     return node;
 }
开发者ID:sprucemedia,项目名称:oinq,代码行数:9,代码来源:ExpressionVisitor.cs


示例9: InvocationExpectation

        /// <summary>
        /// Initializes a new instance of the <see cref="InvocationExpectation"/> class.
        /// </summary>
        /// <param name="lambdaExpression">The lambda expression.</param>
        public InvocationExpectation(LambdaExpression lambdaExpression)
        {
            var expression = lambdaExpression.Body as InvocationExpression;

            if (expression == null)
                throw new ArgumentException("Invalid lambda expression", "lambdaExpression");

            _expression = expression;
        }
开发者ID:mtamme,项目名称:NFake,代码行数:13,代码来源:InvocationExpectation.cs


示例10: Replace

        public static Expression Replace(InvocationExpression invocation)
        {
            LambdaExpression lambda = invocation.Expression as LambdaExpression;
            var replacer = new ExpressionReplacer()
            {
                replacements = 0.To(lambda.Parameters.Count).ToDictionaryEx(i => lambda.Parameters[i], i => invocation.Arguments[i])
            };

            return replacer.Visit(lambda.Body); 
        }
开发者ID:signumsoftware,项目名称:framework,代码行数:10,代码来源:ExpressionReplacer.cs


示例11: VisitInvocation

        protected override Expression VisitInvocation(InvocationExpression node)
        {
            var args = Visit(node.Arguments);
            foreach(var arg in args)
                AddParameter(arg);

            var expr = Visit(node.Expression);
            AddParameter(expr);
            return null;
        }
开发者ID:hazama-yuinyan,项目名称:Expresso,代码行数:10,代码来源:ParameterCollector.cs


示例12: ParseInvokationExpression

        private static ParsedCallExpression ParseInvokationExpression(InvocationExpression expression)
        {
            var target = Helpers.GetValueProducedByExpression(expression.Expression);
            var method = target.GetType().GetMethod("Invoke");

            return new ParsedCallExpression(
                calledMethod: method,
                callTargetExpression: expression.Expression,
                argumentsExpressions: from argument in expression.Arguments.Zip(method.GetParameters(), (x, y) => new { Expression = x, ParameterInfo = y })
                                      select new ParsedArgumentExpression(argument.Expression, argument.ParameterInfo));
        }
开发者ID:rajeshpillai,项目名称:FakeItEasy,代码行数:11,代码来源:CallExpressionParser.cs


示例13: VisitInvocation

 protected override Expression VisitInvocation(InvocationExpression node)
 {
     ConstantExpression varNameExpr;
     ParameterExpression contextExpr;
     if ((contextExpr = node.Expression as ParameterExpression) != null &&
         contextExpr.Name == _contextVarName &&
         node.Arguments.Count == 1 &&
         (varNameExpr = node.Arguments[0] as ConstantExpression) != null)
     {
         Variables.Add((string)varNameExpr.Value);
     }
     return base.VisitInvocation(node);
 }
开发者ID:wpq0,项目名称:Tiny-Expression-Evaluator,代码行数:13,代码来源:VariableEnumerator.cs


示例14: AutoInline

		internal Expression AutoInline(InvocationExpression expression)
		{
			this.isLocked = true;
			if (expression == null) throw new ArgumentNullException("expression");
			var lambda = (LambdaExpression) expression.Expression;
			var childScope = new ExpressionRewriter(this);
			var lambdaParams = lambda.Parameters;
			var invokeArgs = expression.Arguments;
			if (lambdaParams.Count != invokeArgs.Count) throw new InvalidOperationException("Lambda/invoke mismatch");
			for (int i = 0; i < lambdaParams.Count; i++)
			{
				childScope.Subst(lambdaParams[i], invokeArgs[i]);
			}
			return childScope.Apply(lambda.Body);
		}
开发者ID:trullock,项目名称:MuonKit.Csv,代码行数:15,代码来源:ExpressionRewriter.cs


示例15: VisitInvocation

        protected override Expression VisitInvocation(InvocationExpression node)
        {
            var baseResult = (InvocationExpression)base.VisitInvocation(node);

            if (baseResult.Expression.NodeType == ExpressionType.Call)
            {
                var methodCallExpression = (MethodCallExpression)baseResult.Expression;

                if (IsCompileMethod(methodCallExpression.Method))
                {
                    Expression result;
                    if (TrySubstituteExpression(methodCallExpression.Object, baseResult.Arguments, out result))
                        return result;
                }
            }

            return baseResult;
        }
开发者ID:IharBury,项目名称:expressions,代码行数:18,代码来源:ExpressionExpander.cs


示例16: VisitInvocation

 protected override Expression VisitInvocation(InvocationExpression iv)
 {
     this.Write("Invoke(");
     this.WriteLine(Indentation.Inner);
     this.VisitExpressionList(iv.Arguments);
     this.Write(", ");
     this.WriteLine(Indentation.Same);
     this.Visit(iv.Expression);
     this.WriteLine(Indentation.Same);
     this.Write(")");
     this.Indent(Indentation.Outer);
     return iv;
 }
开发者ID:PaybackMan,项目名称:Cinder,代码行数:13,代码来源:ExpressionWriter.cs


示例17: VisitInvocation

 protected virtual Expression VisitInvocation(InvocationExpression iv)
 {
     IEnumerable<Expression> args = this.VisitExpressionList(iv.Arguments);
     Expression expr = this.Visit(iv.Expression);
     return this.UpdateInvocation(iv, expr, args);
 }
开发者ID:Bitwix,项目名称:XeroAPI.Net,代码行数:6,代码来源:ExpressionVisitor.cs


示例18: VisitInvocation

 /// <summary>
 /// InvocationExpression visit method
 /// </summary>
 /// <param name="iv">The InvocationExpression to visit</param>
 /// <returns>The visited InvocationExpression</returns>
 internal override Expression VisitInvocation(InvocationExpression iv)
 {
     this.cantTranslateExpression = true;
     return iv;
 }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:10,代码来源:ExpressionWriter.cs


示例19: VisitInvocation

		protected virtual Expression VisitInvocation (InvocationExpression invocation)
		{
			Expression[] args;
			bool changed = VisitExpressionList (invocation.Arguments, out args);

			Expression e = Visit (invocation.Expression);
			changed = (e != invocation.Expression) || changed;

			if (changed)
				return Expression.Invoke (e, args);

			return invocation;
		}
开发者ID:kstreet,项目名称:Street.MvxPlugins,代码行数:13,代码来源:ExpressionVisitor.cs


示例20: VisitInvocation

 /// <summary>
 /// Visits an InvocationExpression.
 /// </summary>
 /// <param name="node">The InvocationExpression.</param>
 /// <returns>The InvocationExpression.</returns>
 protected override Expression VisitInvocation(InvocationExpression node)
 {
     throw new NotImplementedException();
 }
开发者ID:mpobrien,项目名称:mongo-csharp-driver,代码行数:9,代码来源:ExpressionPrettyPrinter.cs



注:本文中的System.Linq.Expressions.InvocationExpression类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Expressions.LabelTarget类代码示例发布时间:2022-05-26
下一篇:
C# Expressions.ExpressionVisitor类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap