views:

77

answers:

1

I have a custom implementation of IResourceProvider and ResourceProviderFactory. Now the default way of making sure ASP.NET uses these custom types is to use the web.config and specify the factory like so:

<globalization resourceProviderFactoryType="Product.Globalization.TranslationResourceProviderFactory" />

This works perfectly, except that in my resource provider I need database access. I want to use my IoC-container(Ninject) to inject the repositories needed to access this data into the CustomResourceProvider. But how am I going to do this? I have no control over the instantiation of the factory, so the factory can't get a reference to my IoC.

Is there any way to register a custom provider programmatically, in for example the Global.asax?

A: 

Your custom implementation of ResourceProviderFactory could use the DI framework to retrieve the instance of IResourceProvider.

Darin Dimitrov
Yes, but how do I get a reference to my DI framework? I think it's an anti-pattern to make my "kernel" statically available in some singleton class.
Robert Massa
There doesn't really seem to be another way, i've used the WCF implementation at http://github.com/idavis/ninject.extensions.wcf/blob/master/source/Ninject.Extensions.Wcf/KernelContainer.cs to do this. Thanks for you input.
Robert Massa