Last active
October 6, 2015 12:18
-
-
Save jgeurts/2992417 to your computer and use it in GitHub Desktop.
Configure StructureMap dependency resolver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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