unity-interception

Unity: Register two interfaces as one singleton with interception

老子叫甜甜 提交于 2020-01-22 20:28:06
问题 I have a class that implements two interfaces, and I want to apply interception to the class's methods. I'm following the advice in Unity Register two interfaces as one singleton, but I'm surprised by the results. In a nutshell, it seems that my CallHandler is called twice. The shortest example I have is this: public interface I1 { void Method1(); } public interface I2 { void Method2(); } public class C : I1, I2 { [Log] public void Method1() {} public void Method2() {} } public class

Unity registration by convention with interface interceptor causes “[type] is not interceptable” exception

旧巷老猫 提交于 2019-12-23 12:16:00
问题 I want to register all classes that implements a specific interface into Unity with the WithMappings.FromMatchingInterface convention. In addition, I want all of the registered objects to be intercepted using an interface interception behaviour. The problem is that Unity also registers mappings between the concrete classes, and when those classes are resolved, an exception is thrown with the message: "[type] is not interceptable" I realise that resolving an object using the concrete class

Microsoft Unity base class interception

Deadly 提交于 2019-12-13 06:12:28
问题 I have an application that has a base class and derived classes from it with each implementation class having it's own interface. I would like to use Unity's interception for exception handling on derived types of a base class. I am new to interception so I don't know all the quirks. As far as I know, I have to register interception with each implementation resolve. The point is that all of my implementations have a base class, so I thought that I could skip the redundancy and set the

Unity(3.5) Interception Not Working in MVC

旧城冷巷雨未停 提交于 2019-12-12 03:16:53
问题 I am trying to incorporate Interception using PolicyInjectionBehavior and get the this error: Exception information: Exception type: ResolutionFailedException Exception message: Resolution of the dependency failed, type = "CSR.Presentation.Controllers.HomeController", name = "(none)". Exception occurred while: Calling constructor Microsoft.Practices.Unity.InterceptionExtension.PolicyInjectionBehavior(Microsoft.Practices.Unity.InterceptionExtension.CurrentInterceptionRequest

Registration by convention and interception causes ResolutionFailedException

非 Y 不嫁゛ 提交于 2019-12-12 01:49:10
问题 Simple scenario public interface IFoo { int GetData(); } public class Foo : IFoo { [CacheResult] public int GetData() { .... } } public class MyController { [Dependency] IFoo Foo {get; set;} } If I register the interface manually, resolving MyController works fine: container.RegisterType<IFoo, Foo>(new ContainerControlledLifetimeManager(), new InterceptionBehavior<PolicyInjectionBehavior>(), new Interceptor<InterfaceInterceptor>()); var controller = container.Resolve<MyController>(); If I try

Microsoft Unity the difference between interface interception and constructor Injection

余生颓废 提交于 2019-12-11 01:14:30
问题 What's the difference between interface interception and constructor Injection in asp.net unity? I am lack of understanding DI with Unity I am working on an old project and in unity.config, some like this, <register type="ICRIC2012TrialUserService" mapTo="CRIC2012TrialUserService"> <lifetime type="perthread"/> <interceptor type="InterfaceInterceptor"/> <policyInjection/> </register> but some do not have <interceptor type="InterfaceInterceptor"/> but in project these class and interface work

Full stack trace for intercepted methods at call site in Unity

眉间皱痕 提交于 2019-12-10 14:21:20
问题 We're looking into using Unity to handle logging service methods with interception. However, one concern is that the full stack trace is not available at the call site; its only available within an interceptor call. Here's an example setup: public interface IExceptionService { void ThrowEx(); } public class ExceptionService : IExceptionService { public void ThrowEx() { throw new NotImplementedException(); } } public class DummyInterceptor : IInterceptionBehavior { public IEnumerable<Type>

ASP.NET Identity 2 - injecting ISecureDataFormat<>

对着背影说爱祢 提交于 2019-12-10 11:19:28
问题 I'm having same issue described here with no answer, just using Unity. I'm trying to register ISecureDataFormat<> in the lastest VS2013 (update 2) SPA/Web Api template. I've tried container.RegisterType(typeof(ISecureDataFormat<>), typeof(SecureDataFormat<>)); container.RegisterType<ISecureDataFormat<AuthenticationTicket>, SecureDataFormat<AuthenticationTicket>>(); container.RegisterType<ISecureDataFormat<AuthenticationTicket>, TicketDataFormat>(); It "works" but not really because then it

Resolve multiple implementation of a single interface in unity

点点圈 提交于 2019-12-08 12:30:18
问题 I have the following scenario : public interface IFoo { } public interface IFoo3 { } public class Foo4 : IFoo3 { } public class Foo1 : IFoo { } public class Foo2 : IFoo { Foo2 (IFoo object1, IFoo3 object2) } on the client side : IUnityContainer container = new UnityContainer(); container.RegisterType<IFoo, Foo1>("Foo1"); container.RegisterType<IFoo3, Foo4>(); container.RegisterType<IFoo, Foo2>("Foo2"); IFoo3 obj = container.Resolve<IFoo3>(); //Resolve 1 IFoo obj2 = container.Resolve<IFoo>();

ASP.NET Identity 2 - injecting ISecureDataFormat<>

ぃ、小莉子 提交于 2019-12-06 05:10:26
I'm having same issue described here with no answer, just using Unity. I'm trying to register ISecureDataFormat<> in the lastest VS2013 (update 2) SPA/Web Api template. I've tried container.RegisterType(typeof(ISecureDataFormat<>), typeof(SecureDataFormat<>)); container.RegisterType<ISecureDataFormat<AuthenticationTicket>, SecureDataFormat<AuthenticationTicket>>(); container.RegisterType<ISecureDataFormat<AuthenticationTicket>, TicketDataFormat>(); It "works" but not really because then it complains about the next depenedency in that tree, IDataSerializer... and then the next IDataProtector,