当前位置: 首页>>代码示例>>C#>>正文


C# Expressions.ParameterExpression类代码示例

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


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


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