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


C# LambdaExpression.ToString方法代码示例

本文整理汇总了C#中System.Linq.Expressions.LambdaExpression.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# LambdaExpression.ToString方法的具体用法?C# LambdaExpression.ToString怎么用?C# LambdaExpression.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Linq.Expressions.LambdaExpression的用法示例。


在下文中一共展示了LambdaExpression.ToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LambdaExpressionCacheKey

		public LambdaExpressionCacheKey(LambdaExpression obj)
		{
			ReturnType = obj.ReturnType.FullName;
			ExpressionAsString = obj.ToString();
			ArgTypes = new HashSet<string>(obj.Parameters.Select(x => x.Type.FullName));
			_toString = null;
		}
开发者ID:Xamarui,项目名称:Examine,代码行数:7,代码来源:LambdaExpressionCacheKey.cs

示例2: FilterPredicate

 public FilterPredicate(LambdaExpression lambda)
 {
     Util.Check(lambda.Parameters.Count > 0, "Invalid FilterPredicate lambda - must have at least one Entity parameter.");
       Util.Check(lambda.Body.Type == typeof(bool), "Invalid FilterPredicate lambda - must have bool return type.");
       Lambda = lambda;
       EntityType = Lambda.Parameters[0].Type;
       _asString = lambda.ToString();
 }
开发者ID:yuanfei05,项目名称:vita,代码行数:8,代码来源:_FilterPredicate.cs

示例3: ValidateOpAssignConversionLambda

 private static void ValidateOpAssignConversionLambda(LambdaExpression conversion, Expression left, MethodInfo method, ExpressionType nodeType)
 {
     Type delegateType = conversion.Type;
     Debug.Assert(typeof(System.MulticastDelegate).IsAssignableFrom(delegateType) && delegateType != typeof(System.MulticastDelegate));
     MethodInfo mi = delegateType.GetMethod("Invoke");
     ParameterInfo[] pms = mi.GetParametersCached();
     Debug.Assert(pms.Length == conversion.Parameters.Count);
     if (pms.Length != 1)
     {
         throw Error.IncorrectNumberOfMethodCallArguments(conversion);
     }
     if (!TypeUtils.AreEquivalent(mi.ReturnType, left.Type))
     {
         throw Error.OperandTypesDoNotMatchParameters(nodeType, conversion.ToString());
     }
     if (method != null)
     {
         // The parameter type of conversion lambda must be the same as the return type of the overload method
         if (!TypeUtils.AreEquivalent(pms[0].ParameterType, method.ReturnType))
         {
             throw Error.OverloadOperatorTypeDoesNotMatchConversionType(nodeType, conversion.ToString());
         }
     }
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:24,代码来源:BinaryExpression.cs

示例4: Coalesce

        /// <summary>
        /// Creates a BinaryExpression that represents a coalescing operation.
        /// </summary>
        /// <param name="left">An <see cref="Expression"/> to set the <see cref="P:BinaryExpression.Left"/> property equal to.</param>
        /// <param name="right">An <see cref="Expression"/> to set the <see cref="P:BinaryExpression.Right"/> property equal to.</param>
        /// <param name="conversion">A LambdaExpression to set the Conversion property equal to.</param>
        /// <returns>A BinaryExpression that has the NodeType property equal to Coalesce and the Left, Right and Conversion properties set to the specified values.
        /// </returns>
        public static BinaryExpression Coalesce(Expression left, Expression right, LambdaExpression conversion)
        {
            RequiresCanRead(left, nameof(left));
            RequiresCanRead(right, nameof(right));

            if (conversion == null)
            {
                Type resultType = ValidateCoalesceArgTypes(left.Type, right.Type);
                return new SimpleBinaryExpression(ExpressionType.Coalesce, left, right, resultType);
            }

            if (left.Type.GetTypeInfo().IsValueType && !TypeUtils.IsNullableType(left.Type))
            {
                throw Error.CoalesceUsedOnNonNullType();
            }

            Type delegateType = conversion.Type;
            Debug.Assert(typeof(System.MulticastDelegate).IsAssignableFrom(delegateType) && delegateType != typeof(System.MulticastDelegate));
            MethodInfo method = delegateType.GetMethod("Invoke");
            if (method.ReturnType == typeof(void))
            {
                throw Error.UserDefinedOperatorMustNotBeVoid(conversion, nameof(method));
            }
            ParameterInfo[] pms = method.GetParametersCached();
            Debug.Assert(pms.Length == conversion.Parameters.Count);
            if (pms.Length != 1)
            {
                throw Error.IncorrectNumberOfMethodCallArguments(conversion);
            }
            // The return type must match exactly.
            // We could weaken this restriction and
            // say that the return type must be assignable to from
            // the return type of the lambda.
            if (!TypeUtils.AreEquivalent(method.ReturnType, right.Type))
            {
                throw Error.OperandTypesDoNotMatchParameters(ExpressionType.Coalesce, conversion.ToString());
            }
            // The parameter of the conversion lambda must either be assignable
            // from the erased or unerased type of the left hand side.
            if (!ParameterIsAssignable(pms[0], TypeUtils.GetNonNullableType(left.Type)) &&
                !ParameterIsAssignable(pms[0], left.Type))
            {
                throw Error.OperandTypesDoNotMatchParameters(ExpressionType.Coalesce, conversion.ToString());
            }
            return new CoalesceConversionBinaryExpression(left, right, conversion);
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:54,代码来源:BinaryExpression.cs

示例5: NotSupportedExpressionException

 public NotSupportedExpressionException(LambdaExpression expression, string message, Exception innerException)
     : base(message + Environment.NewLine + expression.ToString(), innerException)
 {
         Expression = expression;
 }
开发者ID:calebjenkins,项目名称:linq2ga,代码行数:5,代码来源:NotSupportedExpressionException.cs

示例6: GetFirstMember

        private static MemberExpression GetFirstMember(LambdaExpression expression)
        {
            if (expression.Body is BinaryExpression)
                return ((BinaryExpression)expression.Body).Left as MemberExpression;

            if (expression.Body is MemberExpression)
                return expression.Body as MemberExpression;

            if (expression.Body is UnaryExpression && expression.Body.NodeType == ExpressionType.Convert)
                return ((UnaryExpression)expression.Body).Operand as MemberExpression;

            throw new UnableToGetTheFirstMember(expression.ToString());
        }
开发者ID:stalinvr007,项目名称:VoDB,代码行数:13,代码来源:ExpressionBreaker.cs

示例7: VisitMethodCall

 protected override Expression VisitMethodCall(MethodCallExpression m)
 {
     if (m.Method.DeclaringType == typeof(Queryable) && m.Method.Name == "Where")
     {
         this.Visit(m.Arguments[0]);
         queryTextBuilder.Append(" WHERE ");
         LambdaExpression lambda = (LambdaExpression)StripQuotes(m.Arguments[1]);
         this.Visit(lambda.Body);
         return m;
     }
     else if (m.Method.DeclaringType == typeof(Queryable) && m.Method.Name == "Single")
     {
         this.Visit(m.Arguments[0]);
         return m;
     }
     else if (m.Method.DeclaringType == typeof(Queryable) && m.Method.Name == "Select")
     {
         this.Visit(m.Arguments[0]);
         queryTextBuilder.Append(" SELECT ");
         selectMethod = (LambdaExpression)StripQuotes(m.Arguments[1]);
         queryTextBuilder.Append(selectMethod.ToString());
         return m;
     }
     throw new NotSupportedException(string.Format("The method '{0}' is not supported", m.Method.Name));
 }
开发者ID:brendankowitz,项目名称:systembusinessobjects,代码行数:25,代码来源:QueryTranslater.cs

示例8: ValidateConversion

        private static Type ValidateConversion(CSharpExpressionType nodeType, Type inputType, LambdaExpression conversion)
        {
            var invoke = conversion.Type.GetMethod("Invoke");

            var invokeParameters = invoke.GetParametersCached();
            if (invokeParameters.Length != 1)
            {
                throw LinqError.IncorrectNumberOfMethodCallArguments(conversion);
            }

            if (!TypeUtils.AreEquivalent(invokeParameters[0].ParameterType, inputType))
            {
                throw LinqError.OperandTypesDoNotMatchParameters(nodeType, conversion.ToString());
            }

            return invoke.ReturnType;
        }
开发者ID:taolin123,项目名称:ExpressionFutures,代码行数:17,代码来源:AssignBinaryCSharpExpression.cs

示例9: GetLambda

 private void GetLambda(LambdaExpression lambda)
 {
     if (lambda.Body.Type != typeof(void))
     {
         terms.Push(Expression.Constant(
                         new BoxedConstant(lambda.ToString()))
                    );
     }
 }
开发者ID:lfont,项目名称:PetaPoco,代码行数:9,代码来源:SQLExpressionParser.cs


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