I worked a little with StructureMap and I managed to inject in my controller (through constructor injection) a concrete type repository for an interface.
Now, I need to inject a repository type into my custom membership provider. But how? My custom membership provider is created through Membership.Provider.ValidateUser
(for example).
For controller I created a class like this:
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 inject an concrete type in my custom membership provider with StructureMap?