Policy Injection with Stand-alone Interception

Aug 9, 2011 at 12:21 PM

Hi Forum

I need to use a CallHandler/Policy Injection using Stand-alone interception.

I need to use the PerformanceCounterCallHandler. I can get it to work by configuration and also programatically by using a container.

There are several examples of using a container programatically (see link below). It is quite expensive this way. I need to be able to set it up using Standalone Interception. (Through the Intercept. class). As I read it - the interception should be the same whether it is used via a Container or the Intercept class. 


Registering Policy Injection Components

Using Interception in Applications


Hope somone can help.

Best regards,









Aug 9, 2011 at 12:57 PM

I figured it out. Here is the code:

    public static T HookMeUP<T>(T instance)
                   where T : class
            var behaviors = new List<IInterceptionBehavior> { };

            var interceptor = new InterfaceInterceptor();

            var request = new CurrentInterceptionRequest(interceptor, typeof(T), instance.GetType());
            var policies = new InjectionPolicy[] { new AttributeDrivenPolicy() };
            var behaviour = new PolicyInjectionBehavior(request, policies, null);


            return Intercept.ThroughProxy(instance, new InterfaceInterceptor(), behaviors);