示例#1
0
        public object Create(Type proxyType, IInterceptor interceptor, params Type[] interfaces)
        {
            var adapter = new CastleInterceptorAdapter(interceptor, null);

            return(proxyType.IsInterface ?
                   factory.CreateInterfaceProxyWithoutTarget(proxyType, interfaces, adapter) :
                   factory.CreateClassProxy(proxyType, interfaces, adapter));
        }
示例#2
0
        public TProxy Create <TProxy>(TProxy target, IInterceptor interceptor, params Type[] interfaces)
        {
            var adapter = new CastleInterceptorAdapter(interceptor, target);

            return(typeof(TProxy).IsInterface ?
                   (TProxy)factory.CreateInterfaceProxyWithoutTarget(typeof(TProxy), interfaces, adapter) :
                   (TProxy)factory.CreateClassProxy(typeof(TProxy), interfaces, adapter));
        }
示例#3
0
        public TProxy Create <TProxy>(object[] ctorArguments, IInterceptor interceptor, params Type[] interfaces)
            where TProxy : class
        {
            //TODO: It should infer the ctor paramenters, no reason to pass in ctorArguments, proxy has no target
            var target  = (TProxy)Activator.CreateInstance(typeof(TProxy), ctorArguments);
            var adapter = new CastleInterceptorAdapter(interceptor, target);

            return((TProxy)factory.CreateClassProxy(typeof(TProxy), interfaces, Castle.DynamicProxy.ProxyGenerationOptions.Default, ctorArguments, adapter));
        }