Add properties to a custom membership provider using a lock

So far, in reading about injection options for custom membership providers, I have found two possible ways to do this:

One of the following: http://bugsquash.blogspot.com/2010/11/windsor-managed-membershipproviders.html

Here, the author basically offers to register your user provider, and then have a rather dubious adapter for the windsurper for membership (I do not really like the way in which your provider uses the container that it receives from HttpApplication, which it eventually wraps with the Windsor adapter).

This is another similar option: http://code.google.com/p/webdotnet/source/browse/trunk/Steeg.Framework/Web/Security/MemberShipProvider.cs?r=2

If you just override Initialize()and manually specify the dependencies there. At least in the first case, you do not need the dependencies of the instances manually (except for the provider itself).

Then there are a few that also suggest using some kind of service locator (MVC or otherwise)

Then I met ninject, adding dependencies to properties on Membership.Providerpretty easily with something like _kernel.Inject(Membership.Provider). This is much closer to what I want, preserving the concept of the root of the composition, which primarily attracted me to use DI.

How can I achieve a similar result with the lock?

: , . Ninject

№1? , . .

+2
1

, , (), ( ). Service Locator, , , . Jonas Gauffin ​​ MVC ( DependencyResolver), ( NuGet), .

-, , web.config, DependencyResolver.Current. , DependencyResolverMembershipProvider - , . .

+2

All Articles