Skip to content

Instantly share code, notes, and snippets.

@hyrmn
Created May 17, 2010 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyrmn/403858 to your computer and use it in GitHub Desktop.
Save hyrmn/403858 to your computer and use it in GitHub Desktop.
ObjectFactory.Initialize(i =>
{
i.IgnoreStructureMapConfig = true;
i.AddRegistry(new NHibernateRegistry());
i.Scan(s =>
{
s.Assembly("Hyrmn.Web");
s.WithDefaultConventions();
});
i.For<IEmailer>().Use<Emailer>()
.Ctor<string>("username").EqualToAppSetting("emailUsername")
.Ctor<string>("password").EqualToAppSetting("emailPassword");
i.For<IAuthenticationService>().Singleton().Use<FormsAuthenticationService>();
});
public class StructureMapControllerFactory : DefaultControllerFactory
{
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
{
if (controllerType != null)
return ObjectFactory.GetInstance(controllerType) as Controller;
return base.GetControllerInstance(requestContext, controllerType);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment