Skip to content

Instantly share code, notes, and snippets.

@jgeurts
Last active October 6, 2015 12:18
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 jgeurts/2992417 to your computer and use it in GitHub Desktop.
Save jgeurts/2992417 to your computer and use it in GitHub Desktop.
Configure StructureMap dependency resolver
using System.Web.Mvc;
using MvcKickstart.Infrastructure;
using StructureMap;
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(YourProject.IocConfig), "PreStart", Order = -100)]
// This gets installed automatically with the MvcKickstart nuget (https://nuget.org/packages/mvckickstart)
namespace YourProject
{
public static class IocConfig
{
public static void PreStart()
{
// If changes need to be made to IocRegistry, please subclass it and replace the following line
ObjectFactory.Initialize(x => x.AddRegistry(new IocRegistry(typeof(IocConfig).Assembly)));
DependencyResolver.SetResolver(new StructureMapDependencyScope(ObjectFactory.Container));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment