Created
July 13, 2014 21:26
-
-
Save StacyGay/d02b8a0d3adfdcff64c6 to your computer and use it in GitHub Desktop.
Bootstrapper example
This file contains 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
public class Bootstrapper | |
{ | |
public static IUnityContainer Initialise() | |
{ | |
var container = BuildUnityContainer(); | |
var containerManager = new SessionContainerManager(container); | |
var dependencyResolver = new DependencyResolver(containerManager); | |
var controllerFactory = new ControllerFactory(container, containerManager); | |
DependencyResolver.SetResolver(dependencyResolver); | |
ControllerBuilder.Current.SetControllerFactory(controllerFactory); | |
ModelBinderProviders.BinderProviders.Add(new InterfaceModelBinderProvider()); | |
return container; | |
} | |
private static IUnityContainer BuildUnityContainer() | |
{ | |
var container = new UnityContainer(); | |
// register all your components with the container here | |
// it is NOT necessary to register your controllers | |
RegisterTypes(container); | |
return container; | |
} | |
public static void RegisterTypes(IUnityContainer container) | |
{ | |
container.RegisterType<IViewPageActivator, CustomViewPageActivator>(); | |
container.RegisterType<IClientConfigRepo, ClientConfigRepo>(); | |
InterfaceFactory.RegisterAllModules(container); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment