using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; using Castle.ActiveRecord.Framework; using System.Configuration; using Castle.ActiveRecord; using Ninject.Core; using NinjectMvc.Helpers; using ActiveRecordScaffolding.Controllers; using Castle.ActiveRecord.Framework.Config; using System.IO; namespace ActiveRecordScaffolding { public class GlobalApplication : System.Web.HttpApplication { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults ); } protected void Application_Start() { //---------------------------------------------------------------------------------------------------- // Make it possible to use sqlserver ce in asp.net courtesy of: // http://joeydotnet.com/blog/archive/2007/06/29/SQL-Server-CE---Great-for-prototyping-and-testing.aspx AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true); //---------------------------------------------------------------------------------------------------- RegisterRoutes(RouteTable.Routes); IDictionary props = new Dictionary(); props.Add("connection.driver_class", "NHibernate.Driver.SqlServerCeDriver"); props.Add("dialect", "NHibernate.Dialect.MsSqlCeDialect"); props.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider"); //string dbpath = Path.Combine(Environment.CurrentDirectory, @"ActiveRecordScaffolding\App_Data\Northwind.sdf"); string dbpath = @"C:\svn\EightyProofSolutions\public\ActiveRecordScaffolding\ActiveRecordScaffolding\App_Data\Northwind.sdf"; props.Add("connection.connection_string", String.Format("Data Source={0}", dbpath)); InPlaceConfigurationSource source = new InPlaceConfigurationSource(); source.Add(typeof(ActiveRecordBase), props); ActiveRecordStarter.Initialize(typeof(ARController<>).Assembly, source); IKernel kernel = new StandardKernel(new ARControllerModule(typeof(ARController<>).Assembly)); ControllerBuilder.Current.SetControllerFactory(new NinjectControllerFactory(kernel)); } } }