public override Expression <TDelegate> ToLambda()
        {
            Method method = null;
            ICecilArgumentsResolver typeResolver = null;

            NRefactory.MethodDeclaration methodDeclaration = null;
            var genericTypesTransformerVisitor             = new GenericTypesTransformerVisitor();
            var lambdaExpressionVisitor       = new LambdaExpressionVisitor <NRefactory.MethodDeclaration>();
            MethodDefinition methodDefinition = _methodInfo.ResolveMethodDefinition();

            if (methodDefinition.HasGenericParameters)
            {
                var types = _methodInfo.GetGenericArguments();
                typeResolver = new MethodDefinitionTypesResolver(methodDefinition, types);
            }
            else
            {
                typeResolver = DummyArgumentsResolver.Instance;
            }

            methodDeclaration = methodDefinition.ResolveMothod <NRefactory.MethodDeclaration>();
            methodDeclaration = methodDeclaration.AcceptVisitor(typeResolver, genericTypesTransformerVisitor);
            methodDeclaration = methodDeclaration.AcceptVisitor(lambdaExpressionVisitor);
            method            = AstExpression.Method(methodDeclaration, Context, new NRefactoryAstVisitor());

            return(Expression.Lambda <TDelegate>(method, method.Parameters));
        }
示例#2
0
        public static Method Method(NRefactory.MethodDeclaration methodDeclaration, object context, INRefcatoryExpressionVisitor visitor, IScope scope = null)
        {
            Method methodBlock = null;

            if (!methodDeclaration.IsCompilerGeneratorEnumerator(ref methodBlock))
            {
                methodBlock = new MethodDeclaration(methodDeclaration, context, scope, visitor);
            }

            return(methodBlock);
        }
示例#3
0
        public bool CheckMethod(ICS.MethodDeclaration node, InspectionData data)
        {
            if ((MatchKind != 0 && (MatchKind & DeclarationKinds.Method) == 0) || !CheckAttributedNode(node, ICS.Modifiers.Private))
            {
                return(false);
            }

            string name = node.Name;

            if (IsValid(name))
            {
                return(true);
            }

            data.Add(GetFixableResult(node.NameToken.StartLocation, null, name));
            return(true);
        }
示例#4
0
 public virtual S VisitMethodDeclaration(MethodDeclaration methodDeclaration, T data)
 {
     return(VisitChildren(methodDeclaration, data));
 }
示例#5
0
 void IAstVisitor.VisitMethodDeclaration(MethodDeclaration methodDeclaration)
 {
     Visit(EnterMethodDeclaration, LeaveMethodDeclaration, methodDeclaration);
 }
示例#6
0
        public override void VisitMethodDeclaration(ICSharpCode.NRefactory.CSharp.MethodDeclaration methodDeclaration)
        {
            base.VisitMethodDeclaration(methodDeclaration);

            AddMethod(methodDeclaration, methodDeclaration.Body);
        }
 public virtual S VisitMethodDeclaration(MethodDeclaration methodDeclaration, T data)
 {
     throw new NotImplementedException();
 }
示例#8
0
 public override AstExpression VisitMethodDeclaration(NRefactory.MethodDeclaration methodDeclaration, IScope scope)
 {
     throw new NotImplementedException();
 }