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)); }
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)); }
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)); }