public static Route Parse(Uri url, Settings settings) { var route = new Route(); var path = url.AbsolutePath; var parts = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries).ToList(); switch(parts.Count) { case 0: route.Controller = settings.DefaultController; route.Action = "index"; break; case 1: route.Controller = parts[0]; route.Action = "index"; break; default: route.Controller = parts[0]; route.Action = parts[1]; break; } if(parts.Count > 2) { // todo lo que pase de module/controller/action son parámetros route.Parameters = parts.Skip(2).ToArray(); } return route; }
public Sessions(Settings settings) { CookieExpirationDays = 60; persistent = settings["persistentSessions"] as bool? ?? false; connectionString = settings["ConnectionString"] as string; databaseType = settings["databaseType"] as string; }
public MvcContext(HttpRequest request, Settings settings, Sessions sessions) { this.sessions = sessions; var route = Route.Parse(request.Url, settings); this.Route = route; this.Request = request; this.Settings = this.Settings; }
public static Orm NewOrm(Settings settings) { if(settings.DatabaseType == null) { throw new NullReferenceException("DatabaseType is not set. Check settings.conf"); } if(settings.ConnectionString == null) { throw new NullReferenceException("ConnectionString is not set. Check settings.conf"); } return new Orm(DbSession.New(settings.DatabaseType, settings.ConnectionString)); }
public AppServer(Settings settings) { this.settings = settings; this.sessions = new Sessions(settings); this.Init(); }