vgquotes/Src/VideoGameQuotes.Web/Global.asax.cs

51 lines
2.2 KiB
C#
Raw Normal View History

2011-02-10 04:39:59 +00:00
using System.Web.Mvc;
2011-02-09 03:50:45 +00:00
using System.Web.Routing;
2011-02-10 04:39:59 +00:00
using Microsoft.Practices.Unity;
using Portoa.Web;
using Portoa.Web.Models;
2011-02-10 04:39:59 +00:00
using Portoa.Web.Unity;
using UnityGenerics;
2011-02-10 04:39:59 +00:00
using VideoGameQuotes.Api;
using VideoGameQuotes.Api.Persistence;
using VideoGameQuotes.Web.Security;
using VideoGameQuotes.Web.Services;
2011-02-09 03:50:45 +00:00
namespace VideoGameQuotes.Web {
public class MvcApplication : MvcApplicationBase {
protected override void ConfigureModelBinders(ModelBinderDictionary binders) {
binders.Add<Region, FlagEnumModelBinder>();
}
2011-02-10 04:39:59 +00:00
protected override void ConfigureUnity() {
Container
.AddNewExtension<ConfigureLog4Net>()
.Configure<ILog4NetConfigurator>()
.SetName("VideoGameQuotes.Web")
.UseXml();
2011-02-10 04:39:59 +00:00
Container
.AddNewExtension<LogAllMethodCalls>()
.RegisterType<ICurrentUserProvider, SessionBasedUserProvider>()
.RegisterType<IsValidUserAttribute>(new InjectionProperty<IsValidUserAttribute>(attr => attr.UserProvider))
2011-02-10 04:39:59 +00:00
.RegisterType<IUserService, UserService>()
.RegisterType<IQuoteService, QuoteService>()
2011-02-10 04:39:59 +00:00
.RegisterType<IUserRepository, UserRepository>();
}
2011-02-09 03:50:45 +00:00
2011-02-10 04:39:59 +00:00
protected override void RegisterRoutes(RouteCollection routes) {
2011-02-09 03:50:45 +00:00
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
2011-02-10 04:39:59 +00:00
routes.IgnoreRoute("media/{*anything}");
2011-02-09 03:50:45 +00:00
2011-02-11 05:21:31 +00:00
routes.MapRoute("about", "about", new { controller = "Home", action = "About" });
routes.MapRoute("contact", "contact", new { controller = "Home", action = "Contact" });
routes.MapRoute("submit", "submit", new { controller = "Quote", action = "Submit" });
2011-02-14 08:55:54 +00:00
routes.MapRoute("search", "search", new { controller = "Quote", action = "Search" });
routes.MapRoute("recent", "recent", new { controller = "Quote", action = "Recent" });
routes.MapRoute("random", "random", new { controller = "Quote", action = "Random" });
routes.MapRoute("create-category", "category/create", new { controller = "Quote", action = "CreateCategory" });
routes.MapRoute("individual-quote", "quote/{id}/{*text}", new { controller = "Quote", action = "Quote" }, new { id = @"\d+" });
2011-02-11 05:21:31 +00:00
routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });
2011-02-09 03:50:45 +00:00
}
}
}