Jul 14, 2012 at 7:12 PM
Edited Jul 14, 2012 at 7:12 PM
|
Hi,
I am quite new to Unity. As I figured out it is possible to do interception to objects of classes which are registered to UnityContainer in a manner as
IUnityContainer container = new UnityContainer();
container.AddNewExtension<Interception>();
container.RegisterType<ISubscriberRepository, SubscriberRepository>();
container.Configure<Interception>().SetInterceptorFor<ISubscriberRepository>(
new InterfaceInterceptor()
);
ISubscriberRepository repository = container.Resolve<ISubscriberRepository>();
My requirement is to be able to mark several methods in my application with my custom attibutes which I derive from InterceptionExtention.HandlerAttribute.
After that it would be great if I would not need to register each and every single type as e.g.
container.RegisterType<ISubscriberRepository, SubscriberRepository>();
container.Configure<Interception>().SetInterceptorFor<ISubscriberRepository>(
new InterfaceInterceptor()
);
as I need to be very flexible in my application. Imagine I have a NullHandlerAttribute which I need to place on specific methods during ongoing development phase.
Requiering to always enhance the setup doing container.RegisterType would be quite tedious.
Is there a way to avoid that?
Another question: If my application itself must not know about Unity. Is there a way to instantiate the objects without using container.Reslove<..>?
Regards Peter
|