Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void Application_Start()
- {
- AreaRegistration.RegisterAllAreas();
- RegisterGlobalFilters(GlobalFilters.Filters);
- RegisterRoutes(RouteTable.Routes);
- RegisterCastle();
- }
- private void RegisterCastle()
- {
- _container = new WindsorContainer();
- _container.Install(FromAssembly.InDirectory(new AssemblyFilter(HttpRuntime.BinDirectory)));
- ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(_container.Kernel));
- }
- kernel.Load(AppDomain.CurrentDomain.GetAssemblies());
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Castle.Facilities.TypedFactory;
- using Castle.MicroKernel;
- using Castle.MicroKernel.Registration;
- using Castle.Windsor;
- using Castle.Windsor.Installer;
- using DFW.Domain.Interfaces;
- using UI.App_Start;
- using UI.Windsor;
- [assembly: WebActivator.PostApplicationStartMethod(typeof(Bootstrapper), "Wire")]
- [assembly: WebActivator.ApplicationShutdownMethod(typeof(Bootstrapper), "DeWire")]
- namespace UI.App_Start
- {
- public class Bootstrapper
- {
- private static readonly IWindsorContainer Container = new WindsorContainer();
- public static void Wire()
- {
- //To be able to inject IEnumerable<T> ICollection<T> IList<T> T[] use this:
- //container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel, true));
- //Documentation http://docs.castleproject.org/Windsor.Resolvers.ashx
- //To support typed factories add this:
- Container.AddFacility<TypedFactoryFacility>();
- Container.Register(Component.For<IServiceFactory>().AsFactory().LifestyleTransient());
- //Documentation http://docs.castleproject.org/Windsor.Typed-Factory-Facility.ashx
- Container.Install(FromAssembly.This()).Install(FromAssembly.Named("APP.Infrastructure.DependencyResolution"));
- var controllerFactory = new WindsorControllerFactory(Container.Kernel);
- ControllerBuilder.Current.SetControllerFactory(controllerFactory);
- }
- public static void DeWire()
- {
- Container.Dispose();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement