public ContextManager(ContextAdapter adapter) { ctx = adapter; handlers.Add(new InstanceHandler()); handlers.Add(new StaticFileHandler() {BaseFolder = "/../../../../../../QCloud/qode/src/assets", Name = "assets"}); handlers.Add(new StaticFileHandler() {BaseFolder = "res"}); }
public HandleResult Handle(ContextAdapter context) { var rlt = new HandleResult(); try { Handle(context, rlt); } catch (Exception ex) { rlt.Error(ex); } return rlt; }
protected override void Handle(ContextAdapter context, HandleResult rlt) { if (!string.IsNullOrWhiteSpace(Name) && !string.Equals(context.Request.Url.Instance, Name, StringComparison.OrdinalIgnoreCase)) { return; } var route = context.Request.Url.Route; if (!string.IsNullOrWhiteSpace(Name)) { route = route.Replace(Name, string.Empty); } //var path = route.PathMap(AppDomain.CurrentDomain.BaseDirectory + "res"); var path = route.PathMap(BaseFolder.PathAbs()); var ext = path.PathExt(); var dtype = Dobj.Get<string>(settings.Instance.mime, "*"); var etype = Dobj.Get<string>(settings.Instance.mime, ext); if (!string.IsNullOrWhiteSpace(etype)) { context.Response.Type(etype); } else { context.Response.Type(dtype); } if (File.Exists(path)) { var s = File.Open(path, FileMode.Open); context.Response.Write(s); rlt.Set(true); } else { context.Response.Type("text/html"); } }
protected abstract void Handle(ContextAdapter context, HandleResult result);
protected override void Handle(ContextAdapter context, HandleResult rlt) { var iname = context.Request.Url.Instance; var aname = context.Request.Url.Action; var typename = Dobj.Get<string>(settings.Instance.mapping, iname); if (typename != null) { var o = ReflectionExtensions.CreateInstance(typename, null, context); if (o != null) { try { context.Response.Type("text/html"); var result = (o is BizUnit) ? ((BizUnit) o).Execute(aname, context.Request.Url.RouteArgs) : ReflectionExtensions.Invoke(o.GetType(), aname, o, context.Request.Url.RouteArgs); if (result == null) { // Do nothing (void); } else if (result is ActionStep) { var ar = (ActionStep) result; ar.Execute(context); } else if (result is Stream) { context.Response.Write((Stream) result); } else { context.Response.Write(result.ToString()); } rlt.Set(true); } catch (Exception ex) { context.Response.Status(403); context.Response.Type("text/html"); log.e(ex); } } } }
public LhBizUnit(ContextAdapter context) : base(context) { }
public TestBizUnit(ContextAdapter context) : base(context) { }
public BizUnit(ContextAdapter context) { cx = context; }
public override void Execute(ContextAdapter context) { context.Response.Header("Location", Location); context.Response.Status(302); }
public abstract void Execute(ContextAdapter context);