Created
March 26, 2011 15:34
-
-
Save Itslet/888371 to your computer and use it in GitHub Desktop.
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
using Castle.Windsor; | |
using Castle.Windsor.Installer; | |
using CastleDemo.Plumbing; | |
using Castle.MicroKernel.Registration; | |
namespace CastleDemo | |
{ | |
// Note: For instructions on enabling IIS6 or IIS7 classic mode, | |
// visit http://go.microsoft.com/?LinkId=9394801 | |
public class MvcApplication : System.Web.HttpApplication,IContainerAccessor | |
{ | |
public static void RegisterGlobalFilters(GlobalFilterCollection filters) | |
{ | |
filters.Add(new HandleErrorAttribute()); | |
} | |
public static void RegisterRoutes(RouteCollection routes) | |
{ | |
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); | |
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" }); | |
routes.MapRoute( | |
"Default", // Route name | |
"{controller}/{action}/{id}", // URL with parameters | |
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults | |
); | |
} | |
protected void Application_Start() | |
{ | |
AreaRegistration.RegisterAllAreas(); | |
RegisterGlobalFilters(GlobalFilters.Filters); | |
RegisterRoutes(RouteTable.Routes); | |
BootstrapContainer(); | |
} | |
public void Application_End() | |
{ | |
container.Dispose(); | |
} | |
private static void BootstrapContainer() | |
{ | |
container = new WindsorContainer() | |
.Install(FromAssembly.This()); | |
var controllerFactory = new WindsorControllerFactory(container.Kernel); | |
ControllerBuilder.Current.SetControllerFactory(controllerFactory); | |
} | |
static IWindsorContainer container; | |
public IWindsorContainer Container | |
{ | |
get { return container; } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment