public void ProcessRequest(System.Web.HttpContext context) { IPayLoad cxt = new ComponentPayLoad(); IHandler handler = VenusContainerLoader.Container.TryLookup(typeof(IHandler), cxt.Controller) as IHandler; cxt = CreatePayLoad(handler); string content = handler.Process(cxt); if (cxt.Type == RenderType.Xml) { context.Response.ContentType = "application/xml"; } else { context.Response.ContentType = "text/html"; } context.Response.ContentEncoding = Encoding.UTF8; context.Response.Write(content); }
private IPayLoad CreatePayLoad(IHandler handler) { if (handler is ConfigBeanHandler) { ConfigurationPayLoad config = new ConfigurationPayLoad(); if (config.ConfigType == "files") { config.Type = RenderType.Xml; } else { config.Type = ContextHelper.GetRenderType(); } return config; } ComponentPayLoad component = new ComponentPayLoad(); component.Type = ContextHelper.GetRenderType(); return component; }
public void ProcessRequest(HttpContext context) { IPayLoad pay = new ComponentPayLoad(); //判断是不是请求IP if (IsLocalHost(pay)) { VerifyMessage vf = VerifyProcess(pay); if (!vf.IsSuccess) { ISerializer serializer = GetSerializer(pay); if (!string.IsNullOrEmpty(vf.Message)) { context.Response.Write(serializer.Serializer(vf)); } } IHandler handler = VenusContainerLoader.Container.TryLookup(typeof(IHandler), pay.Controller) as IHandler; if (handler == null) { ComponentResult result = new ComponentResult() { Code = 404, Message = "Not found Controller : " + pay.Controller }; context.Response.ContentEncoding = Encoding.UTF8; context.Response.Write(CommonHelper.CreateComponentResult(result, pay.Type)); return; } pay = CreatePayLoad(handler); string content = handler.Process(pay); if (pay.Type == RenderType.Xml) { context.Response.ContentType = "application/xml"; } else { context.Response.ContentType = "text/html"; } context.Response.ContentEncoding = Encoding.UTF8; context.Response.Write(content); } else { context.Response.Write(NetAccess.Instance.GetProxyContent(pay.TargetIP, pay.RequestUrl)); } }
public void NoExistIDTest() { bool success = false; try { IPayLoad pay = new ComponentPayLoad(); IHandler facade = VenusContainerLoader.Container.TryLookup(typeof(IHandler), pay.Controller) as IHandler; string result = facade.Process(pay); if (!string.IsNullOrEmpty(result)) { success = true; } else { success = false; } } catch { success = false; } Assert.IsTrue(success); }