Questions tagged [unity-interception]

Unity is an IOC/DI framework from the Microsoft Enterprise Patterns and Practices Library. It also has cross-cutting (Aspect like) capabilities in the form of Interceptors

Unity allows developers to wire up Interceptors to be injected at the class or method level. This gives the developer the ability to introduce logic that is invoked anytime a method on the configured class/method is called. This magic is possible when Unity is used as an Object Factory, where it creates a dynamic proxy class in front of the implementation class at runtime.

72 questions
3
votes
1 answer

Is interception worth the overhead it creates?

I'm in the middle of a significant effort to introduce NHibernate into our code base. I figured I would have to use some kind of a DI container, so I can inject dependencies into the entities I load from the database. I chose Unity as that…
telewin
  • 1,102
  • 8
  • 17
3
votes
2 answers

.NET Unity Interception using Custom Attributes

I would like to get the behaviour described in the answer here but using configuration through code. The code sample shows custom attribute being created without anything unity related and adding the behaviour through configuration. Custom attribute…
Filip
  • 854
  • 8
  • 17
3
votes
1 answer

Intercepting child method calls using Unity

Using PIAB / Unity, is it possible to intercept "child" method calls ? e.g. the class has three methods ... DoSomething(), DoFirst(), DoSecond() The DoSomething() method calls DoFirst() which in turn calls DoSecond() I can get interception of…
SteveC
  • 15,808
  • 23
  • 102
  • 173
3
votes
2 answers

Why is my custom call handler not called?

I'm trying to understand how to use call handlers with Unity. Here's the code I have so far: void Main() { var container = new UnityContainer(); container.AddNewExtension() .Configure() …
Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758
3
votes
1 answer

Why Unity interception cannot catch Exception?

I got an issue with Unity interception when throw an Exception in my method. Please reference from my sample application as below: class Program { static void Main(string[] args) { var container = new UnityContainer(); …
Tim Phan
  • 311
  • 1
  • 11
3
votes
2 answers

Unity ICallHandler vs. IInterceptionBehavior

It almost seems like Unity is providing 2 different routes to achieve AoP functionality. The question is why? What are the differences? What would be the pros and cons of each approach? For example using…
Alwyn
  • 8,079
  • 12
  • 59
  • 107
2
votes
2 answers

Copying attributes to InterfaceInterceptor generated proxy

Suppose I have an interface exposed over WCF: [ServiceContract] interface IService { [OperationContract] void Foo(); } And an implementation: [ServiceBehavior(...)] class Service : IService { public void Foo() { /* impl */ } } I can…
telewin
  • 1,102
  • 8
  • 17
2
votes
0 answers

UnityConfig.Resolve component failed when unity interception is used

I have problem with resolving component with Unity in my .NET MVC 5 app. In my App_Start folder I have generated UnityConfig.cs and UnityMvcActivator.cs, which looks like this: public static class UnityConfig { #region Unity Container …
2
votes
2 answers

How can the Unity interceptor determine if a call originated from WCF or from an internal service?

I have a WCF service hooked with a Unity interceptor and all calls to the WCF layer is intercepted by Unity for auditing purposes. However, Unity seems to intercept ALL calls to resolve the interface, whether the call originated from WCF or…
Hawk
  • 692
  • 2
  • 7
  • 18
2
votes
1 answer

InvocationContext not persisting contents

I am added a value to the InvocationContext dictionary, however it doesn't persist to the next call. i.e. each call in the chain that's intercepted is returning false for InvocationContext.ContainsKey("tracing-id"). public IMethodReturn…
BanksySan
  • 27,362
  • 33
  • 117
  • 216
2
votes
1 answer

Unity InterceptionBehavior with InjectionConstructor

Is it possible to configure a custom InterceptionBehavior with InjectionConstructor? In other words, how do you tell Unity which constructor on your InterceptionBehavior to use. In order to trace the method flow in our application, I currently…
Andrew
  • 217
  • 2
  • 12
2
votes
1 answer

unity interception from config without using container

Hi I am trying to use unity interception (I don't want to use unity container). I am able to configure run time but don't know how to configure it from config. my code: public interface ICalculator { int Add(int first, int second); int…
vishal mane
  • 296
  • 5
  • 11
2
votes
1 answer

ASP.NET Identity 2 - injecting ISecureDataFormat<>

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<>),…
parliament
  • 21,544
  • 38
  • 148
  • 238
2
votes
1 answer

Difference between Arguments and Inputs in IMethodInvocation

What is the different between the Arguments collection and the Inputs collection in the IMethodInvocation interface? Both are types of IParameterCollection.
BanksySan
  • 27,362
  • 33
  • 117
  • 216
2
votes
0 answers

Debugger step into IInterceptionBehavior. Invoke

I have unity interceptor implemented IInterceptionBehavior.Invoke, everything works just fine, however in VS-debugger if I click step-into on a proxy object, it is not working (I would expect to jump into target method or at least to my Invoke…