60 lines
2.5 KiB
C#
60 lines
2.5 KiB
C#
using System.Web.Mvc;
|
|
using System.Web.Routing;
|
|
using Microsoft.Practices.Unity;
|
|
using Portoa.Web;
|
|
using Portoa.Web.Models;
|
|
using Portoa.Web.Unity;
|
|
using UnityGenerics;
|
|
using VideoGameQuotes.Api;
|
|
using VideoGameQuotes.Api.Persistence;
|
|
using VideoGameQuotes.Web.Controllers;
|
|
using VideoGameQuotes.Web.Models;
|
|
using VideoGameQuotes.Web.Security;
|
|
using VideoGameQuotes.Web.Services;
|
|
|
|
namespace VideoGameQuotes.Web {
|
|
public class MvcApplication : MvcApplicationBase {
|
|
|
|
protected override void ConfigureModelBinders(ModelBinderDictionary binders) {
|
|
binders
|
|
.Add<Region, FlagEnumModelBinder>()
|
|
.Add<BrowseModel, BrowseModelBinder>()
|
|
.Add<ApiModel, ApiModelBinder>();
|
|
}
|
|
|
|
protected override void ConfigureUnity() {
|
|
Container
|
|
.AddNewExtension<ConfigureLog4Net>()
|
|
.Configure<ILog4NetConfigurator>()
|
|
.SetName("VideoGameQuotes.Web")
|
|
.UseXml();
|
|
|
|
Container
|
|
.AddNewExtension<LogAllMethodCalls>()
|
|
.RegisterType<ICurrentUserProvider, SessionBasedUserProvider>()
|
|
.RegisterType<IsValidUserAttribute>(new InjectionProperty<IsValidUserAttribute>(attr => attr.UserProvider))
|
|
.RegisterType<IUserService, UserService>()
|
|
.RegisterType<IQuoteService, QuoteService>()
|
|
.RegisterType<IApiService, ApiService>()
|
|
.RegisterType<IUserRepository, UserRepository>();
|
|
}
|
|
|
|
protected override void RegisterRoutes(RouteCollection routes) {
|
|
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
|
routes.IgnoreRoute("media/{*anything}");
|
|
|
|
|
|
routes.MapRoute("api", "api/{action}/{id}/{*criteria}", new { controller = "Api" }, new { action = "game", id = @"\d+|all" });
|
|
|
|
routes.MapRoute("home", "{action}", new { controller = "Home", action = "Index" }, new { action = "about|contact" });
|
|
|
|
routes.MapRoute("best", "best/{start}-{end}/", new { controller = "Quote", action = "Best" }, new { start = @"\d+", end = @"\d+" });
|
|
routes.MapRoute("browse", "browse/{*qualifiers}", new { controller = "Quote", action = "Browse" });
|
|
routes.MapRoute("quote", "{action}", new { controller = "Quote" }, new { action = "submit|search|recent|random|best|vote|report" });
|
|
routes.MapRoute("individual-quote", "quote/{id}/{*text}", new { controller = "Quote", action = "Quote" }, new { id = @"\d+" });
|
|
routes.MapRoute("create-category", "category/create", new { controller = "Quote", action = "CreateCategory" });
|
|
|
|
routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });
|
|
}
|
|
}
|
|
} |