public static void WriteResource(string path, HttpCall call) { #if DEBUG if (EXTERNAL_RESOURCES) { call.Write(File.ReadAllBytes(Path.Combine(sfpath, path))); return; } #endif byte[] data; if (Res.TryGetValue(path, out data)) { call.Write(data, 0, data.Length); } else { throw new Exception("Resource not found"); } }
private void CallNewProcessor(HttpListenerContext ctx) { HttpCall call = new HttpCall(ctx); try { prc(this, call); } catch (Exception e) { call.Response.StatusCode = 500; call.Write(e.GetType().Name + ": " + e.Message); } finally { call.Close(); } }
public static void WriteTemplate(string template, HttpCall call, params object[] para) { #if DEBUG if (EXTERNAL_RESOURCES) { InitResources(); } #endif Templater t; if (Templs.TryGetValue(template, out t)) { call.Write(t.Process(para)); } #if DEBUG else { throw new Exception("No template found for: " + template); } #endif }