private Type GetInvocationType(MetaMethod method, ClassEmitter emitter, ProxyGenerationOptions options) { var scope = emitter.ModuleScope; var key = new CacheKey(method.Method, CompositionInvocationTypeGenerator.BaseType, null, null); // no locking required as we're already within a lock var invocation = scope.GetFromCache(key); if (invocation != null) { return invocation; } invocation = new CompositionInvocationTypeGenerator(method.Method.DeclaringType, method, method.Method, false, null) .Generate(emitter, options, namingScope) .BuildType(); scope.RegisterInCache(key, invocation); return invocation; }
private Type GetInvocationType(MetaMethod method, ClassEmitter @class, ProxyGenerationOptions options) { var scope = @class.ModuleScope; Type[] invocationInterfaces; if (canChangeTarget) { invocationInterfaces = new[] { typeof(IInvocation), typeof(IChangeProxyTarget) }; } else { invocationInterfaces = new[] { typeof(IInvocation) }; } var key = new CacheKey(method.Method, CompositionInvocationTypeGenerator.BaseType, invocationInterfaces, null); // no locking required as we're already within a lock var invocation = scope.GetFromCache(key); if (invocation != null) { return invocation; } invocation = new CompositionInvocationTypeGenerator(method.Method.DeclaringType, method, method.Method, canChangeTarget, null) .Generate(@class, options, namingScope).BuildType(); scope.RegisterInCache(key, invocation); return invocation; }
private MethodGenerator IndirectlyCalledMethodGenerator(MetaMethod method, ClassEmitter proxy, ProxyGenerationOptions options, OverrideMethodDelegate overrideMethod) { var @delegate = GetDelegateType(method, proxy, options); var contributor = GetContributor(@delegate, method); var invocation = new CompositionInvocationTypeGenerator(targetType, method, null, false, contributor) .Generate(proxy, options, namingScope) .BuildType(); return new MethodWithInvocationGenerator(method, proxy.GetField("__interceptors"), invocation, (c, m) => c.GetField("__target").ToExpression(), overrideMethod, contributor); }