74 lines
4.2 KiB
C#
74 lines
4.2 KiB
C#
using System.Web.Mvc;
|
|
using System.Web.Routing;
|
|
using Microsoft.Practices.Unity;
|
|
using Portoa.Search;
|
|
using Portoa.Web;
|
|
using Portoa.Web.Models;
|
|
using Portoa.Web.Security;
|
|
using Portoa.Web.SmartCasing;
|
|
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<User> {
|
|
protected override void ConfigureModelBinders(ModelBinderDictionary binders) {
|
|
binders
|
|
.Add<Region, FlagEnumModelBinder<Region>>()
|
|
.Add<BrowseModel, BrowseModelBinder>()
|
|
.Add<ApiModel, ApiModelBinder>();
|
|
}
|
|
|
|
protected override void ConfigureUnity() {
|
|
Container
|
|
.RegisterType<VerifyUserAttribute>(new InjectionProperty<VerifyUserAttribute>(attr => attr.UserProvider))
|
|
.RegisterAndIntercept<ICurrentUserProvider<User>, SessionBasedUserProvider>()
|
|
.RegisterAndIntercept<IUserService, UserService>()
|
|
.RegisterAndIntercept<IAdministrationService, AdministrationService>()
|
|
.RegisterAndIntercept<IQuoteService, QuoteService>()
|
|
.RegisterAndIntercept<ISystemService, SystemService>()
|
|
.RegisterAndIntercept<ICategoryService, CategoryService>()
|
|
.RegisterAndIntercept<IPublisherService, PublisherService>()
|
|
.RegisterAndIntercept<IGameService, GameService>()
|
|
.RegisterAndIntercept<IApiService, ApiService>()
|
|
.RegisterAndIntercept<IAuthenticationService, FormsAuthenticationService>()
|
|
.RegisterAndIntercept<IUserRepository, UserRepository>();
|
|
}
|
|
|
|
protected override void AfterStartUp() {
|
|
EnableSmartCasing();
|
|
Container.Resolve<ISearchIndexBuilder<Quote, int>>().BuildIndex();
|
|
}
|
|
|
|
protected override void RegisterRoutes(RouteCollection routes) {
|
|
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
|
routes.IgnoreRoute("media/{*anything}");
|
|
|
|
routes.MapRoute("favicon", "favicon.ico", new { controller = "Home", action = "Favicon" });
|
|
|
|
//bullshit route so that RenderAction works
|
|
routes.MapSmartRoute("mainmenu", "home/mainmenu", new { controller = "Home", action = "MainMenu" });
|
|
routes.MapSmartRoute("quote-of-the-day", "quote/quoteoftheday", new { controller = "Quote", action = "QuoteOfTheDay" });
|
|
|
|
routes.MapSmartRoute("crud-default", "{controller}/{action}", null, new { controller = "System|Publisher|Game|Category", action = "Create|Edit|Delete" });
|
|
routes.MapSmartRoute("admin", "Admin/{action}", new { controller = "Admin", action = "Index" }, new { action = "Users|Create|Flags|Password" });
|
|
routes.MapSmartRoute("user-edit", "User/Edit/{usernameOrIp}", new { controller = "User", action = "Edit", usernameOrIp = @"\w+" });
|
|
routes.MapSmartRoute("user-default", "User/{action}/{id}", new { controller = "User", action = "Delete|Ban", id = UrlParameter.Optional });
|
|
routes.MapSmartRoute("api", "Api/{action}/{id}/{*criteria}", new { controller = "Api" }, new { action = "Game|System|Category|Publisher|Quote", id = @"\d+|all" });
|
|
routes.MapSmartRoute("home", "{action}", new { controller = "Home", action = "Index" }, new { action = "About|Contact|Login|Logout" });
|
|
routes.MapSmartRoute("paged", "{action}/{page}", new { controller = "Quote", page = 1 }, new { action = "Best|Recent", page = @"\d+" });
|
|
routes.MapSmartRoute("browse", "Browse/{*qualifiers}", new { controller = "Quote", action = "Browse" });
|
|
routes.MapSmartRoute("search", "Search/{*searchQuery}", new { controller = "Quote", action = "Search" });
|
|
routes.MapSmartRoute("quote-task", "Quote/{action}/{id}", new { controller = "Quote" }, new { action = "Edit", id = @"\d+" });
|
|
routes.MapSmartRoute("quote", "{action}", new { controller = "Quote" }, new { action = "Submit|Recent|Random|Vote|Flag" });
|
|
routes.MapSmartRoute("dismiss-flag", "dismiss-flag", new { controller = "Quote", action = "DismissFlag" });
|
|
routes.MapSmartRoute("individual-quote", "Quote/{id}/{*text}", new { controller = "Quote", action = "Quote" }, new { id = @"\d+" });
|
|
routes.MapSmartRoute("default", "{controller}", new { controller = "Home", action = "Index" });
|
|
}
|
|
}
|
|
} |