private static ControllerRequest CreateControllerRequest(HttpRequestHead request) { var controllerRequest = new ControllerRequest(); var uriComponents = request.Uri.Split('?'); if (uriComponents.Length == 0) { controllerRequest.Path = new string[0]; } else { controllerRequest.Path = (from s in uriComponents[0].Split('/') where !string.IsNullOrWhiteSpace(s) select HttpUtility.UrlDecode(s).Trim()).ToArray(); } controllerRequest.Query = new Dictionary<string, string>(); if (uriComponents.Length >= 2) { var queryParts = uriComponents[1].Split('&'); foreach (string part in queryParts) { var keyValue = part.Split('='); if (keyValue.Length > 0) { controllerRequest.Query.Add(HttpUtility.UrlDecode(keyValue[0]), keyValue.Length > 1 ? HttpUtility.UrlDecode(keyValue[1]) : null); } } } return controllerRequest; }
private static IController CreateController(ControllerRequest controllerRequest) { IController controller = null; if (controllerRequest.Path.Length == 0 || controllerRequest.Path[0] == "Design") { controller = new DesignController(); } else if (controllerRequest.Path[0] == "Data") { controller = new DataController(); } return controller; }