开发者

Castle DynamicProxy Interface Proxy Generation

I have a WindsorContainer.

I have a ILazyComponentLoader (if it matters) and an Interface (ISomething) with an Interceptor attribute on in.

[Interceptor(typeof(DynamicImplementationInterceptor)]
public interface ISomething

I want Windsor to use ProxyGenerator.CreateInterfaceProxyWithoutTarget when resolving the interface via container.Resolve<ISomething>() so that my DynamicImplementationInterceptor can implement all behavior on demand, externally.

I can't seem to find this exact开发者_Go百科 scenario in the documentation...when I register ISomething by using Component.For<ISomething>()...., how do I specify I want this behavior? (presently I get an error about the type being abstract or interface, so it can't be instantiated...)

Thanks!


Windsor will automatically omit the target when you register a component with an interceptor and no implementation, e.g.:

var container = new WindsorContainer();
container.Register(Component.For<DynamicImplementationInterceptor>());
container.Register(Component.For<ISomething>()
    .Interceptors(InterceptorReference.ForType<DynamicImplementationInterceptor>()).First);

No need for any Interceptor attribute

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜