private HttpResponse ProcessRequest(HttpRequest req, Type type) { var y = new HttpResponse(); ClassTranslationInfo ci = _translationInfo.GetOrMakeTranslationInfo(type); if (ci.PageMethod == null) throw new Exception(string.Format("Page method not found in type {0}", type.FullName)); { // prepare sandbox Response.RuntimeResponse = y; Request.RuntimeRequest = req; Script.Get = req.Get; Script.Post = req.Post; Script.Server = req.Server; } Action phpMain = (Action)Delegate.CreateDelegate(typeof(Action), ci.PageMethod); phpMain(); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Wywołanie metody // y.Echo("Mock output"); return y; }
private HttpResponse ProcessRequestInSandbox(HttpRequest x, HttpResponse y, Type type) { try { y = ProcessRequest(x, type); DoLog(string.Format("{0}", y.StatusCode)); return y; } catch (Exception e) { y.StatusCode = HttpStatusCode.InternalServerError; y.Echo(e.Message); DoLog(string.Format("{0} {1}", y.StatusCode, e.Message)); return y; } }
private HttpResponse ProcessRequest(HttpRequest x) { DoLog(string.Format("{0} {1}", x.Method, x.RequestUri)); string script = x.Script; var httpResponse = new HttpResponse(); Type type; if (script.EndsWith("/")) { var g = _indexOrder.Split(' '); foreach (var gg in g) { type = TypeByScript(script + gg); if (type != null) return ProcessRequestInSandbox(x, httpResponse, type); } httpResponse.StatusCode = HttpStatusCode.NotFound; return httpResponse; } type = TypeByScript(script); if (type != null) return ProcessRequestInSandbox(x, httpResponse, type); httpResponse.StatusCode = HttpStatusCode.NotFound; return httpResponse; }