Skip to content

Instantly share code, notes, and snippets.

@benfoster
Created October 31, 2013 10:50
Show Gist options
  • Save benfoster/7247748 to your computer and use it in GitHub Desktop.
Save benfoster/7247748 to your computer and use it in GitHub Desktop.
1 asp.net DI
public static class StructureMapConfig
{
public static void Register()
{
ObjectFactory.Initialize(cfg =>
{
cfg.Scan(scan =>
{
scan.LookForRegistries();
scan.TheCallingAssembly();
});
});
// Set up Microsoft's "1 asp.net" service locators
System.Web.Mvc.DependencyResolver.SetResolver(new StructureMapDependencyResolver(ObjectFactory.Container));
System.Web.Http.GlobalConfiguration.Configuration.DependencyResolver = new StructureMapApiDependencyResolver(ObjectFactory.Container);
Microsoft.AspNet.SignalR.GlobalHost.DependencyResolver = new StructureMapSignalRDependencyResolver(ObjectFactory.Container);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment