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?
source
share