示例#1
0
文件: Route.cs 项目: knocte/Sfx.Mvc
		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;
		}
示例#2
0
		public Sessions(Settings settings)
		{
			CookieExpirationDays = 60;
			persistent = settings["persistentSessions"] as bool? ?? false;
			connectionString = settings["ConnectionString"] as string;
			databaseType = settings["databaseType"] as string;
		}
示例#3
0
		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;
		}
示例#4
0
文件: DbUtil.cs 项目: knocte/Sfx.Mvc
		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));
		}
示例#5
0
		public AppServer(Settings settings)
		{
			this.settings = settings;
			this.sessions = new Sessions(settings);
			this.Init();
		}