PolicyInjection: Wrap When Unable to Instantiate

Topics: Policy Injection Application Block
Dec 31, 2007 at 8:28 PM

I've hit a bit of problem. I would like to wrap a class, specifically a class I wrote that inherits from SessionStateStoreProviderBase. However, I do not, nor can I obtain, control of the instantiation of the class. It is being instantiated and managed by the SessionStateModule class, which is sealed.

I would like to use Policy Injection on my class here, but I am not sure if it is even going to be possible. Is there any way for me to wrap my class even though I can't explicitly call wrap?


Jan 2, 2008 at 12:09 AM

In this case, besides not managing the provider reference, you don't have a class that is suitable for policy injection; even if you define an interface and use it to wrap your instance, you wouldn't be able to replace it in the SessionStateModule.

Is it possible for you to refactor your provider implementation so it relies on an internal an interceptable collaborator to do the actual work? This is probably your best bet...

Jan 2, 2008 at 2:12 AM

Thanks for your response! Your suggestion is genius! That never even occured to me! Just goes to show that I shouldn't try to think when I'm incredibly exhausted.

Thanks for the idea, I'll implement that right away!!