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


C# Expression.GetType方法代码示例

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


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

示例1: GetMutator

 public static IMutableExpression GetMutator(Expression expression)
 {
     if (expression is BinaryExpression)
         return new BinaryExpressionMutator((BinaryExpression)expression);
     if (expression is ConditionalExpression)
         return new ConditionalExpressionMutator((ConditionalExpression)expression);
     if (expression is ConstantExpression)
         return new ConstantExpressionMutator((ConstantExpression)expression);
     if (expression is InvocationExpression)
         return new InvocationExpressionMutator((InvocationExpression)expression);
     if (expression is LambdaExpression)
         return new LambdaExpressionMutator((LambdaExpression)expression);
     if (expression is MemberExpression)
         return new MemberExpressionMutator((MemberExpression)expression);
     if (expression is MethodCallExpression)
         return new MethodCallExpressionMutator((MethodCallExpression)expression);
     if (expression is NewExpression)
         return new NewExpressionMutator((NewExpression)expression);
     if (expression is NewArrayExpression)
         return new NewArrayExpressionMutator((NewArrayExpression)expression);
     if (expression is MemberInitExpression)
         return new MemberInitExpressionMutator((MemberInitExpression)expression);
     if (expression is ListInitExpression)
         return new ListInitExpressionMutator((ListInitExpression)expression);
     if (expression is ParameterExpression)
         return new ParameterExpressionMutator((ParameterExpression)expression);
     if (expression is TypeBinaryExpression)
         return new TypeBinaryExpressionMutator((TypeBinaryExpression)expression);
     if (expression is UnaryExpression)
         return new UnaryExpressionMutator((UnaryExpression)expression);
     throw Error.BadArgument("S0064: Unknown Expression Type '{0}'", expression.GetType());
 }
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:32,代码来源:ExpressionMutatorFactory.cs

示例2: EqualsExact

 internal static Boolean EqualsExact(this Expression self, Expression other)
 {
     return self.GetType() == other.GetType() &&
         self.GetType().GetConvertibleTypes()
             .SelectMany(t => t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
             .All(f => EqualsExact(f.GetValue(self), f.GetValue(other)));
 }
开发者ID:takeshik,项目名称:yacq,代码行数:7,代码来源:Extensions.cs

示例3: ProcessExpression

        protected virtual void ProcessExpression(Expression expression)
        {
            var type = expression.GetType();

            if (type == typeof(MethodCallExpression)
                || typeof(MethodCallExpression).IsAssignableFrom(type))
                ProcessMethodCall(expression as MethodCallExpression);
            else if (type == typeof(BinaryExpression)
                || typeof(BinaryExpression).IsAssignableFrom(type))
                ProcessBinary(expression as BinaryExpression);
            else if (type == typeof(ConstantExpression)
                || typeof(ConstantExpression).IsAssignableFrom(type))
                ProcessConstant(expression as ConstantExpression);
            else if (type == typeof(MemberExpression)
                || typeof(MemberExpression).IsAssignableFrom(type))
                ProcessMemberAccess(expression as MemberExpression);
            else if (type == typeof(UnaryExpression)
                || typeof(UnaryExpression).IsAssignableFrom(type))
                ProcessUnary(expression as UnaryExpression);
            else if (type == typeof(LambdaExpression)
                || typeof(LambdaExpression).IsAssignableFrom(type))
                ProcessLambda(expression as LambdaExpression);
            else if (type == typeof(NewArrayExpression))
                ProcessNewArrayExpression(expression as NewArrayExpression);
            else if (type.BaseType == typeof(LambdaExpression)
                || typeof(LambdaExpression).IsAssignableFrom(type.BaseType))
                ProcessLambda(expression as LambdaExpression);
 
        }
开发者ID:mdcuesta,项目名称:anito.net,代码行数:29,代码来源:AdoTranslatorBase.cs

示例4: Parse

 public Node Parse(Expression e)
 {
     try
     {
         return ParseExpression((dynamic) e);
     }
     catch (RuntimeBinderException exception)
     {
         throw new Exception(string.Format("Unable to dispatch expression of type {0} with node type of {1}", e.GetType().Name, e.NodeType), exception);
     }
 }
开发者ID:wonderful-panda,项目名称:PowerAssert.Net,代码行数:11,代码来源:ExpressionParser.cs

示例5: MemberInfo

 public static MemberInfo MemberInfo(Expression exp)
 {
     Contract.Requires<ArgumentNullException>(exp != null);
     var lambda = exp as LambdaExpression;
     if (lambda == null)
         throw new ArgumentException("exp is no LamdaExpression but a " + exp.GetType().FullName);
     var body = lambda.Body as MemberExpression;
     if (body == null)
         throw new ArgumentException("exp.Body is no Member expression but a " + lambda.Body.GetType());
     return body.Member;
 }
开发者ID:jorik041,项目名称:ChaosUtil,代码行数:11,代码来源:MemberFromLamda.cs

示例6: ExtractMember

 private static MemberInfo ExtractMember(Expression expr)
 {
     switch (expr.NodeType)
     {
         case ExpressionType.Lambda:
             return ExtractMember(((LambdaExpression)expr).Body);
         case ExpressionType.MemberAccess:
             return ((MemberExpression)expr).Member;
         case ExpressionType.Convert:
             return ExtractMember(((UnaryExpression)expr).Operand);
     }
     throw new NotSupportedException(String.Format("Expression of type {0}[{1}] is not supported", expr.NodeType, expr.GetType().Name));
 }
开发者ID:anurse,项目名称:PS-Get,代码行数:13,代码来源:AttributeAssert.cs

示例7: Parse

        public static Node Parse(Expression e)
        {
            if (e.NodeType == ExpressionType.ArrayIndex)
            {
                return ArrayIndex((BinaryExpression)e);
            }
            if (e is BinaryExpression)
            {
                return Binary((BinaryExpression)e, Util.NaturalOperators[e.NodeType]);
            }
            if (e is MemberExpression)
            {
                return Member((MemberExpression)e);
            }
            if (e is ConstantExpression)
            {
                return Constant((ConstantExpression)e);
            }
            if (e is MethodCallExpression)
            {
                return MethodCall((MethodCallExpression)e);
            }
            if (e is ConditionalExpression)
            {
                return Conditional((ConditionalExpression)e);
            }
            if (e is NewArrayExpression)
            {
                return NewArray((NewArrayExpression)e);
            }
            if (e is UnaryExpression)
            {
                return Unary((UnaryExpression)e);
            }
            if (e.NodeType == ExpressionType.Lambda)
            {
                return Lambda(e);
            }
            if (e is TypeBinaryExpression)
            {
                return TypeBinary((TypeBinaryExpression)e);
            }
            if(e is NewExpression)
            {
                return NewObject((NewExpression) e);
            }

            throw new ArgumentOutOfRangeException("e", string.Format("Can't handle expression of class {0} and type {1}", e.GetType().Name, e.NodeType));
        }
开发者ID:Jeff-Lewis,项目名称:Simple.Testing,代码行数:49,代码来源:NaturalExpressionProcessor.cs

示例8: Visit

 public override Expression Visit(Expression exp)
 {
     if (exp != null)
     {
         for (int i = 0; i < level; i++)
         {
             Console.Write(" ");
         }
         Console.WriteLine("{0} - {1}",
         exp.NodeType, exp.GetType().Name);
     }
     level++;
     Expression result = base.Visit(exp);
     level--;
     return result;
 }
开发者ID:sandrapatfer,项目名称:PROMPT11-02-AdvancedProgramming.vilhena,代码行数:16,代码来源:DisplayVisitor.cs

示例9: ParseUnaryExpression

        private static FilterExpression ParseUnaryExpression(Expression expression)
        {
            var unaryExpression = (expression as UnaryExpression).Operand;
            var filterExpression = ParseLinqExpression(unaryExpression);
            switch (expression.NodeType)
            {
                case ExpressionType.Not:
                    return !filterExpression;
                case ExpressionType.Convert:
                    return filterExpression;
                case ExpressionType.Negate:
                    return -filterExpression;
            }

            throw new NotSupportedException(string.Format("Not supported expression of type {0} ({1}): {2}",
                expression.GetType(), expression.NodeType, expression));
        }
开发者ID:nanohex,项目名称:Simple.OData.Client,代码行数:17,代码来源:FilterExpression.Linq.cs

示例10: CreateWithoutResolve

        private ExpressionNode CreateWithoutResolve(Expression expression)
        {
            if (expression is BinaryExpression) return new BinaryExpressionNode(this, expression as BinaryExpression);
            if (expression is ConditionalExpression) return new ConditionalExpressionNode(this, expression as ConditionalExpression);
            if (expression is ConstantExpression) return new ConstantExpressionNode(this, expression as ConstantExpression);
            if (expression is InvocationExpression) return new InvocationExpressionNode(this, expression as InvocationExpression);
            if (expression is LambdaExpression) return new LambdaExpressionNode(this, expression as LambdaExpression);
            if (expression is ListInitExpression) return new ListInitExpressionNode(this, expression as ListInitExpression);
            if (expression is MemberExpression) return new MemberExpressionNode(this, expression as MemberExpression);
            if (expression is MemberInitExpression) return new MemberInitExpressionNode(this, expression as MemberInitExpression);
            if (expression is MethodCallExpression) return new MethodCallExpressionNode(this, expression as MethodCallExpression);
            if (expression is NewArrayExpression) return new NewArrayExpressionNode(this, expression as NewArrayExpression);
            if (expression is NewExpression) return new NewExpressionNode(this, expression as NewExpression);
            if (expression is ParameterExpression) return new ParameterExpressionNode(this, expression as ParameterExpression);
            if (expression is TypeBinaryExpression) return new TypeBinaryExpressionNode(this, expression as TypeBinaryExpression);
            if (expression is UnaryExpression) return new UnaryExpressionNode(this, expression as UnaryExpression);

            throw new ArgumentException("Unknown expression of type " + expression.GetType());
        }
开发者ID:gulbanana,项目名称:Serialize.Linq,代码行数:19,代码来源:NodeContext.cs

示例11: ParseLinqExpression

        private static FilterExpression ParseLinqExpression(Expression expression)
        {
            switch (expression.NodeType)
            {
                case ExpressionType.MemberAccess:
                    return ParseMemberExpression(expression);

                case ExpressionType.Constant:
                    return new FilterExpression((expression as ConstantExpression).Value);

                case ExpressionType.Not:
                case ExpressionType.Convert:
                case ExpressionType.Negate:
                    return ParseUnaryExpression(expression);

                case ExpressionType.Equal:
                case ExpressionType.NotEqual:
                case ExpressionType.LessThan:
                case ExpressionType.LessThanOrEqual:
                case ExpressionType.GreaterThan:
                case ExpressionType.GreaterThanOrEqual:
                case ExpressionType.And:
                case ExpressionType.AndAlso:
                case ExpressionType.Or:
                case ExpressionType.OrElse:
                case ExpressionType.Add:
                case ExpressionType.AddChecked:
                case ExpressionType.Subtract:
                case ExpressionType.SubtractChecked:
                case ExpressionType.Multiply:
                case ExpressionType.MultiplyChecked:
                case ExpressionType.Divide:
                case ExpressionType.Modulo:
                    return ParseBinaryExpression(expression);
            }

            throw new NotSupportedException(string.Format("Not supported expression of type {0} ({1}): {2}", 
                expression.GetType(), expression.NodeType, expression));
        }
开发者ID:nanohex,项目名称:Simple.OData.Client,代码行数:39,代码来源:FilterExpression.Linq.cs

示例12: Visit

        private string Visit(Expression expression)
        {
            switch (expression.NodeType)
            {
                case ExpressionType.Lambda:
                    return this.VisitLambda((LambdaExpression) expression);

                case ExpressionType.Call:
                    return this.MethodMethodCall((MethodCallExpression) expression);

                case ExpressionType.MemberAccess:
                    return this.VisitMember((MemberExpression) expression);

                case ExpressionType.Constant:
                    return this.VisitConstant((ConstantExpression) expression);

                case ExpressionType.Multiply:
                case ExpressionType.Subtract:
                case ExpressionType.Add:
                    return this.VisitBinary((BinaryExpression) expression);
            }

            throw new NotImplementedException(expression.GetType().FullName);
        }
开发者ID:ianw89,项目名称:DragonAid,代码行数:24,代码来源:EquationPrettyTextWriter.cs

示例13: VisitIf

 private static Expression VisitIf(Expression node, Type type, Func<Expression, Expression> func)
 {
     return node.GetType() == type ? func(node) : node;
 }
开发者ID:shadowphoenix,项目名称:IronSilver,代码行数:4,代码来源:AstExpressionVisitor.cs

示例14: ParseBinaryExpression

        private static FilterExpression ParseBinaryExpression(Expression expression)
        {
            var binaryExpression = expression as BinaryExpression;
            var leftExpression = ParseLinqExpression(binaryExpression.Left);
            var rightExpression = ParseLinqExpression(binaryExpression.Right);

            switch (expression.NodeType)
            {
                case ExpressionType.Equal:
                    return leftExpression == rightExpression;
                case ExpressionType.NotEqual:
                    return leftExpression != rightExpression;
                case ExpressionType.LessThan:
                    return leftExpression < rightExpression;
                case ExpressionType.LessThanOrEqual:
                    return leftExpression <= rightExpression;
                case ExpressionType.GreaterThan:
                    return leftExpression > rightExpression;
                case ExpressionType.GreaterThanOrEqual:
                    return leftExpression >= rightExpression;
                case ExpressionType.And:
                case ExpressionType.AndAlso:
                    return leftExpression && rightExpression;
                case ExpressionType.Or:
                case ExpressionType.OrElse:
                    return leftExpression || rightExpression;
                case ExpressionType.Add:
                case ExpressionType.AddChecked:
                    return leftExpression + rightExpression;
                case ExpressionType.Subtract:
                case ExpressionType.SubtractChecked:
                    return leftExpression - rightExpression;
                case ExpressionType.Multiply:
                case ExpressionType.MultiplyChecked:
                    return leftExpression * rightExpression;
                case ExpressionType.Divide:
                    return leftExpression / rightExpression;
                case ExpressionType.Modulo:
                    return leftExpression % rightExpression;
            }

            throw new NotSupportedException(string.Format("Not supported expression of type {0} ({1}): {2}",
                expression.GetType(), expression.NodeType, expression));
        }
开发者ID:nanohex,项目名称:Simple.OData.Client,代码行数:44,代码来源:FilterExpression.Linq.cs

示例15: WriteHeader

 private void WriteHeader(Expression exp)
 {
     WriteLine("{0}:{1} Type={2}", PublicClassName(exp.GetType()), exp.NodeType, FriendlyClassName(exp.Type));
 }
开发者ID:moonreplace,项目名称:mongo-csharp-driver,代码行数:4,代码来源:ExpressionPrettyPrinter.cs


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