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
17
votes
3 answers

Use Unity to intercept all calls to IMyInterface.SomeMethod

I am trying to learn Unity Interceptors and I am having a hard go of it. Say I have an interface like this: public interface IMyInterface { void SomeMethod(); } And I have an unknown number of classes that implement that interface like…
Vaccano
  • 78,325
  • 149
  • 468
  • 850
6
votes
2 answers

Unity: Register two interfaces as one singleton with interception

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…
hibernator
  • 145
  • 1
  • 6
5
votes
3 answers

Using unity interception to solve exception handling as a crosscutting concern

I created my own behavior as follows: public class BoundaryExceptionHandlingBehavior : IInterceptionBehavior { public IEnumerable GetRequiredInterfaces() { return Type.EmptyTypes; } public IMethodReturn Invoke(IMethodInvocation input,…
greyalien007
  • 510
  • 4
  • 13
5
votes
1 answer

Unity Interception Concept Clarity

I being following the Unity Interception link, to implement Unity in my project. By, following a link I have made a class as shown below: [AttributeUsage(AttributeTargets.Method)] public class MyInterceptionAttribute : Attribute { } public class…
user3237621
5
votes
1 answer

Full stack trace for intercepted methods at call site in Unity

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…
Nick
  • 513
  • 3
  • 9
4
votes
1 answer

Getting real instance from proxy under Unity Interception with NHibernate

I'm using Unity to resolve types dynamically for a pluggable architecture. I'm also using interception to apply business rule validation via AOP (using ValidationAspects). Finally, I'm using NHibernate as an ORM to persist domain objects. In order…
Neil Hewitt
  • 2,518
  • 18
  • 24
4
votes
2 answers

Microsoft Unity: Interception not working when using BuildUp instead of Resolve

I am using Microsoft Unity 2.0 and the interception extension is not working as expected. Consider these two lines of code: MyUnityContainer.Configure().SetDefaultInterceptorFor(new VirtualMethodInterceptor()); var someObject =…
Falcon
  • 3,150
  • 2
  • 24
  • 35
4
votes
1 answer

Intercepting object with deep inheritance tree

I'm having object structure with depth of inheritance of 3. Object is implementing single particular interface. The depth of inheritance for interface is 4. My final object is being constructed via unity IoC. I need to intercept every public method…
TechCrap
  • 930
  • 3
  • 14
  • 28
4
votes
1 answer

Auto-generating implementation of interface (proxy without class)

What I would like to achieve is: [Factory] public interface IFooFactory { Foo Create(); } unityContainer.RegisterType( new Interceptor(), new…
4
votes
1 answer

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

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. …
Andrew
  • 217
  • 2
  • 12
4
votes
2 answers

AOP interception attribute

So, i have this problem, and no one seems to be able to help. So rather than keep bashing away i'm going to throw it out there for alternative ways to skin this particular cat. I currently have the following: public interface ICustomerService { …
krisg
  • 796
  • 1
  • 9
  • 24
3
votes
2 answers

Transparent authorization reliability

I need a gear for custom authorization in business logic classes. It has to be permissions based system, but I can not decide how to apply authorization rules to methods. My first thought was to apply custom attributes to…
Tom Kris
  • 1,227
  • 1
  • 8
  • 15
3
votes
2 answers

Unity Interception: How to pass parameter into ICallHandler implementation?

Can I pass message parameter to ICallHandler implementation like this: var logic = container.Resolve(message); And use it like this: IMethodReturn ICallHandler.Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext) { …
3
votes
2 answers

No public constructor is available Unity.Exceptions.InvalidRegistrationException

I have inherited this project, I normally do not unity as my dependency resolver, so forgive me if this is a dumb question. I am getting he following message when I try and resolve a interface. Inner Exception 1: InvalidOperationException: No…
Ashley Kilgour
  • 1,110
  • 2
  • 15
  • 33
3
votes
2 answers

Code based interception/logging configuration for Unity

Im using Unity as IoC container which works fine so far. Now I would like to use interception with a TypeMatchingRule and a LogCallHandler to log all calls to an interface IMyInterface. I'm configuring unity via code, but cannot get logging to work.…
Achim
  • 15,415
  • 15
  • 80
  • 144
1
2 3 4 5