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, InterfaceInvocationTypeGenerator.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 InterfaceInvocationTypeGenerator(method.Method.DeclaringType,
                                                              method,
                                                              method.Method,
                                                              canChangeTarget)
                         .Generate(@class, options, namingScope).BuildType();

            scope.RegisterInCache(key, invocation);

            return(invocation);
        }
        private Type GetInvocationType(MetaMethod method, ClassEmitter emitter, ProxyGenerationOptions options)
        {
            var scope = emitter.ModuleScope;
            var key   = new CacheKey(method.Method, InterfaceInvocationTypeGenerator.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 InterfaceInvocationTypeGenerator(method.Method.DeclaringType,
                                                              method,
                                                              method.Method,
                                                              false)
                         .Generate(emitter, options, namingScope).BuildType();

            scope.RegisterInCache(key, invocation);

            return(invocation);
        }