예제 #1
0
        public T CreateDelegateProxy <T>(object baseObject, IInvocationInterceptor invocationInterceptor)
        {
            ProxyBase <T> .CheckConstructorArguments(baseObject, invocationInterceptor);

            var delegateType = typeof(T);

            if (!delegateType.IsDelegateType())
            {
                throw new ArgumentException(string.Format("{0} is not an delegate", delegateType));
            }

            var proxyType = proxyTypeCache.GetProxyType(delegateType, CreateProxyTypeForDelegate);

            return((T)CreateDelegate(proxyType, delegateType, baseObject, invocationInterceptor));
        }
예제 #2
0
        public T CreateInterfaceProxy <T>(object baseObject, IInvocationInterceptor invocationInterceptor)
        {
            ProxyBase <T> .CheckConstructorArguments(baseObject, invocationInterceptor);

            var interfaceType = typeof(T);

            if (!interfaceType.IsInterface)
            {
                throw new ArgumentException(string.Format("{0} is not an interface", interfaceType));
            }

            var proxyType = proxyTypeCache.GetProxyType(interfaceType, CreateProxyTypeForInterface);

            return((T)CreateInstance(proxyType, baseObject, invocationInterceptor));
        }