Created
February 8, 2011 20:09
-
-
Save jptoto/817113 to your computer and use it in GitHub Desktop.
global.asax
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
namespace WebUI | |
{ | |
// Note: For instructions on enabling IIS6 or IIS7 classic mode, | |
// visit http://go.microsoft.com/?LinkId=9394801 | |
public class MvcApplication : NinjectHttpApplication | |
{ | |
public static void RegisterRoutes(RouteCollection routes) | |
{ | |
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); | |
routes.MapRoute(null, | |
"", // Only matches the empty URL (i.e. ~/) | |
new { controller = "Home", action = "Index" } | |
); | |
routes.MapRoute( | |
"Default", // Route name | |
"{controller}/{action}/{id}", // URL with parameters | |
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults | |
); | |
} | |
protected override void OnApplicationStarted() | |
{ | |
RegisterRoutes(RouteTable.Routes); | |
//RegisterAllControllersIn(Assembly.GetExecutingAssembly()); | |
} | |
protected override IKernel CreateKernel() | |
{ | |
return Container; | |
} | |
internal class SiteModule : NinjectModule | |
{ | |
public override void Load() | |
{ | |
// Bindings | |
Bind<INHibernateSessionFactoryBuilder>().To<NHibernateSessionFactoryBuilder>().InSingletonScope(); | |
Bind<ISession>().ToMethod(context => context.Kernel.Get<INHibernateSessionFactoryBuilder>().GetSessionFactory().OpenSession()); | |
Bind<ICloudFileRepository>().To<SqlCloudFileRepository>(); | |
Bind<IUserRepository>().To<SqlUserRepository>(); | |
} | |
} | |
static IKernel _container; | |
public static IKernel Container | |
{ | |
get | |
{ | |
if (_container == null) | |
{ | |
_container = new StandardKernel(new SiteModule()); | |
} | |
return _container; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment