Skip to content

Instantly share code, notes, and snippets.

@StacyGay
Created July 13, 2014 21:26
Show Gist options
  • Save StacyGay/d02b8a0d3adfdcff64c6 to your computer and use it in GitHub Desktop.
Save StacyGay/d02b8a0d3adfdcff64c6 to your computer and use it in GitHub Desktop.
Bootstrapper example
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