PolicyInjectionBehavior

Apr 15, 2010 at 8:03 AM

Can anyone help me how to achieve this?  I know how to do this using the container but I want to be able to use the Intercept class and apply the policies defined in the Policy Injection Application Block.

IMyInterface proxy = (IMyInterface)Intercept.ThroughProxy(typeof(IMyInterface), new MyClass(), new InterfaceInterceptor(), new [] { //what to put here });

I know the PolicyInjectionBehavior implements the IInterceptionBehavior but I don't know how to go about creating an instance of it specifically what parameters to pass.

summers

Apr 15, 2010 at 6:19 PM

PolicyInjectionBehavior is a fairly special beast, and unfortunately requires the container to properly wire up all the call handlers. You could try doing it by hand, but it's not pretty and not easy.

 

 

Apr 16, 2010 at 12:42 AM

Thanks ctavares for your reply.

I'm not clear though on this, do you mean to say that I would have to manually configure a PipelineManager for the PolicyInjectionBehavior object? or make use of its other constructor, the one which takes  

interceptionqrequest, injectionpolicies, and an instance of a unity container?

 



summers

 

Apr 16, 2010 at 5:18 AM

The types used by the PolicyInjectionBehavior (specifically the PolicySet class) have a hard dependency on the container. You could try to wire up just the policy set via a container and do the rest manually, but at that point it's much, much easier to just do everything through Unity.

 

Apr 16, 2010 at 7:11 AM

Thanks for your quick response, guess I'll just go for the container approach.

I have another question though, and it's the same as with this thread - http://unity.codeplex.com/Thread/View.aspx?ThreadId=209513.  I don't know how to setup the built in call handlers in the <interception> section of the unity section. In addition, when do we setup policies in the <interception> and <extensionConfig> section?  'Coz the documentation provides samples showing policy defined in both elements.

Apr 16, 2010 at 8:08 PM

The current documentation is a terrible mix of old and new stuff. We're working through the edits now.

<extensionConfig> is dead, gone, buried, and is not valid in the config file anymore. Look at the config files in the unit tests for now for how to define policies, I'm rewriting the docs between bug fixes.

 

Apr 19, 2010 at 1:42 AM

Thanks for your help!