using MESWebSite.CommonClass; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace MESWebSite.HttpHandlers { public abstract class BaseHandler : IHttpHandler { public bool IsReusable { get { return false; } } public string Page { get { return GetParam("page").DefaultValue("0"); } } public string Rows { get { return GetParam("rows").DefaultValue("15"); } } public HttpRequest Request = null; public HttpResponse Response = null; public Dictionary MethodDict; public BaseHandler() { MethodDict = new Dictionary(); RegisterAction(QueryList); RegisterAction(SaveInfo); RegisterAction(DelInfo); } protected void RegisterAction(Action action) { MethodDict.Add(action.Method.Name, action); } public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; Request = context.Request; Response = context.Response; string method = Request.Params["method"]; MethodDict[method](); } public string GetParam(string name) { return Request.Params[name]; } protected abstract void QueryList(); protected abstract void SaveInfo(); protected abstract void DelInfo(); } }