I have what I consider to be the standard .NET MVC3 repository template project I played / studied with. This is a fairly standard structure.
- Repository project (with caching infrastructure mentioned below)
- Domain Model Project
- Service Level Project
- MVC Presentation Project
I came across a script when I need to introduce a private member of a class that has only a static constructor that does not give me luck to install the constructor.
This class is a wrapper for using the AppFabric caching implementation that I just completed. (For those who are so addicted, my implementation is based on http://cgeers.wordpress.com/2010/07/04/windows-server-appfabric-caching/ )
Essentially I have:
- interface ICacheProvider
- class DefaultCacheProvider: ICacheProvider
- Cache static class (using any implementation I introduced)
The static class cache is where I would like to introduce ICacheProvider that DefaultCacheProvider will allow.
private static readonly ICacheProvider CacheProvider; static Cache() {
Based on what I read, it looks like a script for ServiceLocator, but I saw some very strong opinions on this (anti-pattern, etc. etc.) that my familiarity with it is low so I not sure about an implementation that will work.
I saw a StackOverflow recommendation for developing a Cache class as a standard class and entering ICacheProvider in SingletonScope
kernel.Bind<ICacheProvider>().To<DefaultCacheProvider>().InSingletonScope();
but I personally would prefer a static shell for ease of use.
Is ServiceLocator setting up the path here, or is there something else obvious that I don't know about? If ServiceLocator is the way to go, is there any connection with Ninject to use? I know that Ninject now has the capabilities of a service locator, but did not know how to implement it.
Thanks for any info.
source share