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

C# Expressions.ParameterExpression类代码示例

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

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



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

示例1: CreateCopyComplexArrayTypeFieldExpression

 /// <summary>
 /// Creates an expression that copies a coplex array value from the source to the target. The value will be cloned as well using the dictionary to reuse already cloned objects.
 /// </summary>
 /// <param name="sourceField"></param>
 /// <param name="targetField"></param>
 /// <param name="type"></param>
 /// <param name="objectDictionary"></param>
 /// <returns></returns>
 internal static Expression CreateCopyComplexArrayTypeFieldExpression(Expression sourceField, Expression targetField, Type type, ParameterExpression objectDictionary) {
     return Expression.IfThenElse(
         Expression.Call(objectDictionary, _dictionaryContainsKey, sourceField),
         Expression.Assign(targetField, Expression.Convert(Expression.Call(objectDictionary, _dictionaryGetItem, sourceField), type)),
         Expression.Assign(targetField, Expression.Convert(Expression.Call(Expression.Call(_getTypeClonerMethodInfo, Expression.Call(sourceField, _getTypeMethodInfo)), _invokeMethodInfo, sourceField, objectDictionary), type))
         );
 }
开发者ID:geffzhang,项目名称:Foundatio,代码行数:15,代码来源:CloneExpressionHelper.cs


示例2: CompileBulkImporter

        public override Expression CompileBulkImporter(EnumStorage enumStorage, Expression writer, ParameterExpression document, ParameterExpression alias, ParameterExpression serializer)
        {
            var method = writeMethod.MakeGenericMethod(typeof(string));
            var dbType = Expression.Constant(DbType);

            return Expression.Call(writer, method, alias, dbType);
        }
开发者ID:danielmarbach,项目名称:marten,代码行数:7,代码来源:DocTypeArgument.cs


示例3: ExpressionParser

 public ExpressionParser(ParameterExpression[] parameters, string expression, object[] values)
 {
     if (expression == null)
     {
         throw new ArgumentNullException("expression");
     }
     if (keywords == null)
     {
         keywords = CreateKeywords();
     }
     this.symbols = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
     this.literals = new Dictionary<Expression, string>();
     if (parameters != null)
     {
         this.ProcessParameters(parameters);
     }
     if (values != null)
     {
         this.ProcessValues(values);
     }
     this.text = expression;
     this.textLen = this.text.Length;
     this.SetTextPos(0);
     this.NextToken();
 }
开发者ID:gerasyana,项目名称:Academy,代码行数:25,代码来源:ExpressionParser.cs


示例4: VisitParameter

        protected override Expression VisitParameter(ParameterExpression node)
        {
            if (_expName == null)
                _expName = node.Name;

            return node.Name == _expName && node.Type == _parameterExpression.Type ? _parameterExpression : node;
        }
开发者ID:ianeller-romey,项目名称:FastMapper,代码行数:7,代码来源:ParameterRenamer.cs


示例5: CreateCall

 private static Expression CreateCall(MethodInfo method, ParameterExpression handler, ParameterExpression context, Type handlerType)
 {
     if (method.IsGenericMethod)
     {
         var handlerParameterType = method.GetParameters()[0].ParameterType;
         if (handlerParameterType.IsGenericType)
         {
             var @interface =
                 handlerType.GetInterfaces().FirstOrDefault(
                     i =>
                     i.IsGenericType &&
                     i.GetGenericTypeDefinition() == handlerParameterType.GetGenericTypeDefinition());
             if (@interface != null)
             {
                 method = method.MakeGenericMethod(@interface.GetGenericArguments().Single());
             }
         }
         else
         {
             // bind handler as generic type?
             method = method.MakeGenericMethod(typeof(object));
             //Debugger.Break();
         }
     }
     return Expression.Call(method, handler, context);
 }
开发者ID:muratbeyaztas,项目名称:Simple.Web,代码行数:26,代码来源:PipelineBlock.cs


示例6: Resolve

    public override Expression Resolve (ParameterExpression inputParameter, Expression expressionToBeResolved, ClauseGenerationContext clauseGenerationContext)
    {
      ArgumentUtility.CheckNotNull ("inputParameter", inputParameter);
      ArgumentUtility.CheckNotNull ("expressionToBeResolved", expressionToBeResolved);

      return Source.Resolve (inputParameter, expressionToBeResolved, clauseGenerationContext);
    }
开发者ID:GOArango,项目名称:arangoclient.net,代码行数:7,代码来源:FetchExpressionNodeBase.cs


示例7: ProjectionBuilder

 /// <summary>
 /// Initializes a new instance of the <see cref="MongoWhereClauseExpressionTreeVisitor"/> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 private ProjectionBuilder(IMappingStore mappingStore, ParameterExpression documentParameter)
 {
     this.mappingStore = mappingStore;
     this.resultObjectMappingParameter = documentParameter;
     this.fields = new Document();
     this.memberNames = new Stack<string>();
 }
开发者ID:andoco,项目名称:mongodb-csharp,代码行数:11,代码来源:ProjectionBuilder.cs


示例8: VisitParameter

        protected override Expression VisitParameter(ParameterExpression p)
        {
            if(p.Type == _elementType)
                return new FieldExpression(p, _alias, "*");

            return base.VisitParameter(p);
        }
开发者ID:hitesh97,项目名称:fluent-mongo,代码行数:7,代码来源:FieldBinder.cs


示例9: ToLinqExpression

    // TODO: to be tested
    public override Expression ToLinqExpression( IQueryable queryable, ParameterExpression parameterExpression, string propertyName )
    {
      if( queryable == null )
        throw new ArgumentNullException( "queryable" );

      if( parameterExpression == null )
        throw new ArgumentNullException( "parameterExpression" );

      if( String.IsNullOrEmpty( propertyName ) )
      {
        if( propertyName == null )
          throw new ArgumentNullException( "propertyName" );

        throw new ArgumentException( "PropertyName must not be empty.", "propertyName" );
      }

      string queriedValue = this.Value as string;

      if( queriedValue == null )
        queriedValue = string.Empty;
      else
        queriedValue = queriedValue.Remove( queriedValue.IndexOf( '*' ) );

      return queryable.CreateEndsWithExpression( parameterExpression, propertyName, queriedValue );
    }
开发者ID:wangws556,项目名称:duoduo-chat,代码行数:26,代码来源:EndsWithFilterCriterion.cs


示例10: Optimize

        /**
         * приводит лямбду (x, y, ...) => ... к виду:  (x, y, ...) => fn(p, q, ...)
         *  где fn - оптимизированная лямбда, p, q - предварительно вычисленные выражения
         *
         *  пример:
         *  Func<int, int, Func<int, int, int, int>, int> fn = (int x, int y, Func<int, int, int, int> Foo) => Foo(F(x), F(y), F(2 * y));
         *  Func<int, int, int> optimizedLambda = (int x, int y) => fn(1, 2, (int p, int q, int l) => p > q ? p : (p < l ? l : q));
         */
        public Expression Optimize(LambdaExpression lambda, string functionName)
        {
            if (_methodCalls != null)
                _methodCalls.Clear();
            else
                _methodCalls = new Dictionary<string, MethodCall>();

            _innerLambdaParams = new List<Expression>();

            _functionName = functionName;

            //  получаем оптимизированную лямбду
            Expression fn = BuildInnerLambda(lambda);

            //  копируем параметры для новой лямбды
            ParameterExpression[] parameters = new ParameterExpression[lambda.Parameters.Count];
            lambda.Parameters.CopyTo(parameters, 0);

            //  собираем новую лямбду
            Expression optimizedLambda = Expression.Lambda(
                Expression.Invoke(fn, _innerLambdaParams),
                parameters
            );

            return optimizedLambda;
        }
开发者ID:CosmicPirate,项目名称:ExpressionOptimization,代码行数:34,代码来源:ExpressionOptimizer.cs


示例11: CreateQuery

		//Func<Type, IEnumerable<object>> fnGetObjects;

		#region CreateQuery
		/// <summary>
		/// called during deserialization.
		/// </summary>
		/// <param name="elementType"></param>
		/// <returns></returns>
		public dynamic CreateQuery(Type elementType)
		{
			dynamic ienumerable = this.fnGetObjects(elementType);
			Type enumerableType = ienumerable.GetType();
			if (!typeof(IEnumerable<>).MakeGenericType(elementType).IsAssignableFrom(enumerableType))
			{				
				ienumerable = Enumerable.ToArray(LinqHelper.CastToGenericEnumerable(ienumerable, elementType));				
				//throw new InvalidOperationException(string.Format("Return value Type is {1}. Expected: {0}", typeof(IEnumerable<>).MakeGenericType(elementType), ienumerable.GetType()));
			}
			    

			IQueryable queryable = Queryable.AsQueryable(ienumerable);
			IQueryProvider provider = (IQueryProvider)queryable.Provider;
			Type queryType = typeof(Query<>).MakeGenericType(elementType);
			ConstructorInfo ctor = queryType.GetConstructors()[2];//Query(IQueryProvider provider, Expression expression)
			ParameterExpression[] parameters = new ParameterExpression[] 
				{ 
					Expression.Parameter(typeof(IQueryProvider)),
					Expression.Parameter(typeof(Expression))
				};

			NewExpression newexpr = Expression.New(ctor, parameters);
			LambdaExpression lambda = Expression.Lambda(newexpr, parameters);
			var newFn = lambda.Compile();
			dynamic query = newFn.DynamicInvoke(new object[] { provider, Expression.Constant(queryable) });
			return query;
		}
开发者ID:yonglehou,项目名称:Bermuda,代码行数:35,代码来源:QueryCreator.cs


示例12: ExpressionBuilderParameters

        public ExpressionBuilderParameters(ParameterExpression[] parameters, IQueryProvider queryProvider, Type elementType, IXmlNamespaceResolver namespaceResolver, bool mayRootPathBeImplied, IOperatorImplementationProvider operatorImplementationProvider, Func<Type, IXmlNamespaceResolver, XPathTypeNavigator> navigatorCreator=null)
        {
            Debug.Assert(parameters!=null);
            if (parameters==null)
                throw new ArgumentNullException("parameters");
            Debug.Assert(parameters.Length>0);
            if (parameters.Length==0)
                throw new ArgumentException(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        SR.ArrayShouldHaveElementsException,
                        1,
                        parameters.Length
                    ),
                    "parameters"
                );
            Debug.Assert(queryProvider!=null);
            if (queryProvider==null)
                throw new ArgumentNullException("queryProvider");
            Debug.Assert(elementType!=null);
            if (elementType==null)
                throw new ArgumentNullException("elementType");

            Parameters=new ReadOnlyCollection<ParameterExpression>(parameters);
            ElementType=elementType;
            QueryProvider=queryProvider;
            NamespaceResolver=namespaceResolver;
            MayRootPathBeImplied=mayRootPathBeImplied;
            OperatorImplementationProvider=operatorImplementationProvider;
            NavigatorCreator=navigatorCreator;
        }
开发者ID:mcartoixa,项目名称:GeoSIK,代码行数:31,代码来源:ExpressionBuilderParameter.cs


示例13: ClosureExpression

        public ClosureExpression(Ast.PythonVariable/*!*/ variable, Expression/*!*/ closureCell, ParameterExpression parameter) {
            Assert.NotNull(closureCell);

            _variable = variable;
            _closureCell = closureCell;
            _parameter = parameter;
        }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:7,代码来源:ClosureExpression.cs


示例14: BuildExpression

        private static NewExpression BuildExpression(Type type, ParameterExpression container)
        {
            if (!type.IsGenericTypeDefinition)
            {
                var constructor = GetConstructorInfo(type);
                var parameters = constructor.GetParameters();

                // create the arguments for the constructor	
                var arguments = new List<Expression>();

                foreach (var paramInfo in parameters)
                {
                    var p = Expression.Call(container, "Resolve", new Type[] { paramInfo.ParameterType },
                      new Expression[] { });
                    arguments.Add(p);
                }

                // create the new MyClass( ... ) call
                return Expression.New(constructor, arguments);
            }
            else
            {
                return null;
            }
        }
开发者ID:VictorTomaili,项目名称:Sanity,代码行数:25,代码来源:CreateInstanceDelegateFactory.cs


示例15: VisitParameter

        /// <summary>
        /// If the given variable matches _find, return _replaceWith.  Otherwise, continue default visitation behavior.
        /// </summary>
        /// <param name="node">The expression node being visited</param>
        /// <returns></returns>
        protected override Expression VisitParameter(ParameterExpression node)
        {
            if (node == _find)
                return _replaceWith;

            return base.VisitParameter(node);
        }
开发者ID:kennethuil,项目名称:LINQParserGenerator,代码行数:12,代码来源:VariableSubstituteVisitor.cs


示例16: VisitParameter

		protected override void VisitParameter (ParameterExpression parameter)
		{
			foreach (var param in lambda.Parameters) {
				if (param.Name == parameter.Name && param != parameter)
					throw new InvalidOperationException ("Lambda Parameter not in scope");
			}
		}
开发者ID:Galad,项目名称:SpecFlow,代码行数:7,代码来源:ExpressionValidator.cs


示例17: Compile

 public override Expression Compile(ParameterExpression stateParameterExpression, LabelTarget returnTarget)
 {
     return Expression.IfThenElse(
         Expression.Convert(this.Condition.Compile(stateParameterExpression, returnTarget), typeof(bool)),
         this.Statement.Compile(stateParameterExpression, returnTarget),
         this.ElseStatement.Compile(stateParameterExpression, returnTarget));
 }
开发者ID:johnsonc,项目名称:Protogame,代码行数:7,代码来源:IfElseLogicStatement.cs


示例18: PushParamExpression

 internal void PushParamExpression(ParameterExpression pe)
 {
     StringBuilder basePath = projectionPaths.Last();
     basePaths.Add(pe, basePath.ToString());
     projectionPaths.Remove(basePath);
     parameterExpressions.Push(pe);
 }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:7,代码来源:PathBox.cs


示例19: CoalesceInternal

        private static Expression CoalesceInternal(Expression left, Expression right, MethodInfo isTrue, bool isReverse, out ParameterExpression temp) {
            ContractUtils.RequiresNotNull(left, "left");
            ContractUtils.RequiresNotNull(right, "right");

            // A bit too strict, but on a safe side.
            ContractUtils.Requires(left.Type == right.Type, "Expression types must match");

            temp = Expression.Variable(left.Type, "tmp_left");

            Expression condition;
            if (isTrue != null) {
                ContractUtils.Requires(isTrue.ReturnType == typeof(bool), "isTrue", "Predicate must return bool.");
                ParameterInfo[] parameters = isTrue.GetParameters();
                ContractUtils.Requires(parameters.Length == 1, "isTrue", "Predicate must take one parameter.");
                ContractUtils.Requires(isTrue.IsStatic && isTrue.IsPublic, "isTrue", "Predicate must be public and static.");

                Type pt = parameters[0].ParameterType;
                ContractUtils.Requires(TypeUtils.CanAssign(pt, left.Type), "left", "Incorrect left expression type");
                condition = Expression.Call(isTrue, Expression.Assign(temp, left));
            } else {
                ContractUtils.Requires(TypeUtils.CanCompareToNull(left.Type), "left", "Incorrect left expression type");
                condition = Expression.Equal(Expression.Assign(temp, left), AstUtils.Constant(null, left.Type));
            }

            Expression t, f;
            if (isReverse) {
                t = temp;
                f = right;
            } else {
                t = right;
                f = temp;
            }

            return Expression.Condition(condition, t, f);
        }
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:35,代码来源:BinaryExpression.cs


示例20: Convert

        protected override SequenceConvertInfo Convert(
            ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo, ParameterExpression param)
        {
            var predicate = (LambdaExpression)methodCall.Arguments[1].Unwrap();
            var info      = builder.ConvertSequence(new BuildInfo(buildInfo, methodCall.Arguments[0]), predicate.Parameters[0]);

            if (info != null)
            {
                info.Expression = methodCall.Transform(ex => ConvertMethod(methodCall, 0, info, predicate.Parameters[0], ex));

                if (param != null)
                {
                    if (param.Type != info.Parameter.Type)
                        param = Expression.Parameter(info.Parameter.Type, param.Name);

                    if (info.ExpressionsToReplace != null)
                        foreach (var path in info.ExpressionsToReplace)
                        {
                            path.Path = path.Path.Transform(e => e == info.Parameter ? param : e);
                            path.Expr = path.Expr.Transform(e => e == info.Parameter ? param : e);
                        }
                }

                info.Parameter = param;

                return info;
            }

            return null;
        }
开发者ID:pebezo,项目名称:linq2db,代码行数:30,代码来源:WhereBuilder.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Expressions.TypeBinaryExpression类代码示例发布时间:2022-05-26
下一篇:
C# Expressions.NewExpression类代码示例发布时间: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