Implementation in a custom member provider with StructureMap

I worked a little with StructureMap, and I was able to enter a specific type repository for the interface into the controller (via the constructor).

Now I need to enter the repository type in my custom membership provider. But how? My custom membership provider is created through Membership.Provider.ValidateUser(for example).

For the controller, I created this class:

public class IocControllerFactory : DefaultControllerFactory
{
    protected override IController GetControllerInstance(
        System.Web.Routing.RequestContext requestContext, 
        Type controllerType)
    {
        return (Controller)
            ObjectFactory.GetInstance(controllerType);
    }
}

and in Global.asax, in Application_Start():

//...
ObjectFactory.Initialize(x =>
{
    x.AddRegistry(new ArticleRegistry());
}
                                    );


ControllerBuilder.Current.SetControllerFactory(
    new IocControllerFactory());
//...

But how to inject a specific type into my custom membership provider with StructureMap?

+5
source share
1 answer

In this case, I do not want to inject.

, "factory" , , , , . , -:).

ASP.NET MVC ( 2+), , , DependencyResolver :

DependencyResolver.Current.GetService<IRepository<User>>();

, , ObjectFactory.

+3

All Articles