Created
February 5, 2010 08:56
-
-
Save ToJans/295655 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 System.IO; | |
using System.Web.Mvc; | |
using System.Web.Routing; | |
using Castle.MicroKernel.Registration; | |
using MvcExtensions.Services; | |
using MvcExtensions.Services.Impl; | |
using MvcExtensions.Services.Impl.FluentNHibernate; | |
using Zehnder.Kits.Core.Controllers; | |
using Zehnder.Kits.Core; | |
using Zehnder.Kits.Viewmodel.Shared; | |
using Zehnder.Kits.Core.Services.Impl; | |
using Zehnder.Kits.Core.Services; | |
using Zehnder.Kits.Core.Model.Components; | |
namespace Zehnder.Kits.Web | |
{ | |
// Note: For instructions on enabling IIS6 or IIS7 classic mode, | |
// visit http://go.microsoft.com/?LinkId=9394801 | |
public class MvcApplication : System.Web.HttpApplication | |
{ | |
public static void RegisterRoutes(RouteCollection routes) | |
{ | |
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); | |
routes.MapRoute( | |
"Defaultaspx", // Route name | |
"{controller}.aspx/{action}/{id}", // URL with parameters | |
new { controller = "Dossier", action = "Index", id = "" } // Parameter defaults | |
); | |
routes.MapRoute( | |
"Default", // Route name | |
"{controller}/{action}/{id}", // URL with parameters | |
new { controller = "Dossier", action = "Index", id = "" } // Parameter defaults | |
); | |
} | |
private Database GetDb() | |
{ | |
var myDomainDefinition = new MyDomainDefinition(); | |
var fn = Server.MapPath("~/app_data/kit.db"); | |
var db = new SqlLiteDatabase(fn, myDomainDefinition); | |
if (!File.Exists(fn)) | |
db.CreateDB(); | |
else | |
db.UpdateDB(); | |
return db; | |
} | |
protected void Application_Start() | |
{ | |
RegisterRoutes(RouteTable.Routes); | |
var settings = Properties.Settings.Default; | |
var module = new MvcExtensions.UI.Web.MvcExtensionsModule(); | |
module.Register(GetDb()); | |
module.Container.Register( | |
Component.For<IAuthenticatieContext>().ImplementedBy<WebFormsAuthenticatieContext>().LifeStyle.PerWebRequest, | |
Component.For<IAuthenticatie>().ImplementedBy<Authenticatie>().LifeStyle.PerWebRequest, | |
Component.For<IVerwerkAuthenticatie>().ImplementedBy<VerwerkAuthenticatie>().LifeStyle.PerWebRequest, | |
Component.For<DossierController>().LifeStyle.PerWebRequest, | |
Component.For<KitController>().LifeStyle.PerWebRequest, | |
Component.For<GebruikerController>().LifeStyle.PerWebRequest, | |
Component.For<TestDataController>().LifeStyle.PerWebRequest, | |
Component.For<IVMApplicationProvider>().ImplementedBy<ControllerHelper>().LifeStyle.PerWebRequest, | |
Component.For<IMapper>().ImplementedBy<MyMapper>().LifeStyle.Singleton, | |
Component.For<ISendMail>().Instance(new MailService(settings.SmtpClientHostname)), | |
Component.For<ITestData>().ImplementedBy<TestData>().LifeStyle.PerWebRequest, | |
Component.For<TextGenerator>().LifeStyle.Singleton | |
); | |
module.RegisterClassDerivedFromMyTextInModelBinder(typeof(EmailText)); | |
ControllerBuilder.Current.DefaultNamespaces.Add("Zehnder.Kits.Core.Controllers"); | |
} | |
} | |
} |
This file contains hidden or 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 System; | |
using MvcExtensions.Services; | |
namespace Zehnder.Kits.Core.Services.Impl | |
{ | |
public class MyDomainDefinition: IDomainDefinition | |
{ | |
public MyDomainDefinition() { } | |
// The assembly where to find the domain types | |
public System.Reflection.Assembly DomainAssembly | |
{ | |
get { return typeof(Model.Kit).Assembly; } | |
} | |
// returns the domaintype for the class | |
// DomainType.ClassWithoutBaseClass is also available | |
public DomainType GetDomainType(Type t) | |
{ | |
if (t.Namespace==typeof(Model.Kit).Namespace) | |
return DomainType.Class; | |
else if (t.Namespace==typeof(Model.Components.EmailText).Namespace) | |
return DomainType.Component; | |
else | |
return DomainType.None; | |
} | |
//if !=null write mapping files to disk | |
public string WriteHbmFilesToPath | |
{ | |
get { return @"c:\tmp"; } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment