Unity Container - Register\Resolve classes without interface

Viewed 196

I have created an Attribute Class that internally uses the Call Handler & Unity Interception to intercept the method and performs trace logging. I am using a unity container to Register and create an object of that class type and perform interception. However, this method is limited to the Classes that have their own interface.

Current Code to Invoke the Interception :

 var container = new UnityContainer();
 container.AddNewExtension<Interception>();
 container.RegisterType<Icalculator, Calculator>(new Interceptor<InterfaceInterceptor>(), new InterceptionBehavior<LoggingBehaviorAttribute>());
 var Calc = container.Resolve<Icalculator>();           
 Icalculator Calc = container.Resolve<Icalculator>();

Is there any other syntax\approach using which we can register the class (without interface) using unity container and perform the interception? Please suggest any possible solution or resources to explore to avoid this de-merit.

0 Answers
Related