當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。