public override Expression <TDelegate> ToLambda() { DynamicProxy proxy = GetDynamicProxy(); ConstructorDeclaration constructor = null; IEnumerable <Parameter> outParameters = null; var typeResolver = DummyArgumentsResolver.Instance; IEnumerable <ParameterExpression> parameters = null; var visitor = new GenericTypesTransformerVisitor(); NRefactory.ConstructorDeclaration constructorDeclaration = null; MethodDefinition methodDefinition = _ctor.ResolveConstructorDefinition(); var lambdaExpressionVisitor = new LambdaExpressionVisitor <NRefactory.ConstructorDeclaration>(); constructorDeclaration = methodDefinition.ResolveMothod <NRefactory.ConstructorDeclaration>(); constructorDeclaration = constructorDeclaration.AcceptVisitor(visitor, typeResolver) as NRefactory.ConstructorDeclaration; constructorDeclaration.AcceptVisitor(new ThisAdditionalReturnStatmentVisitor(), null); outParameters = proxy.GetOutParameters(constructorDeclaration); constructor = AstExpression.Constructor(constructorDeclaration, proxy.ProxiedType, outParameters, new NRefactoryAstVisitor()); constructorDeclaration = constructorDeclaration.AcceptVisitor(lambdaExpressionVisitor); parameters = constructor.Parameters.Concat(constructor.ContextParameter); return(Expression.Lambda <TDelegate>( Expression.Block(new[] { constructor.ContextParameter }, constructor), constructor.Parameters)); }
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)); }