コード例 #1
0
ファイル: ProxyFactory.cs プロジェクト: rincewound/MutaGen
        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
ファイル: ProxyFactory.cs プロジェクト: rincewound/MutaGen
        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));
        }