private void RenderResource(Application app, UrlParse parse, Uri url) { if (parse.IsDirectory) { if (url != null && url.Query.StartsWith("??")) { try { string path; ResourceHandler handler = null; string[] array = url.Query.Substring(2).Split(','); string[] paths = new string[array.Length]; for (int i = 0; i < array.Length; ++i) { path = array[i]; if (i == 0) { UrlParse p = new UrlParse(path); handler = ResourceHandler.Parse(p.ExtensionType, p.Extension, false); if (handler == null) { throw new Exception(); } } paths[i] = app.Context.Server.MapPath(string.Concat(parse.Url, path)); } handler.ProcessRequest(app.Context, paths); } catch (Exception) { app.RenderError(404); } } else { app.RenderError(404); } } else { ResourceHandler handler = ResourceHandler.Parse(parse.ExtensionType, parse.Extension, false); if (handler != null && File.Exists(app.Context.Request.PhysicalPath)) { handler.ProcessRequest(app.Context, app.Context.Request.PhysicalPath); } else { app.RenderError(404); } } }
internal static void RenderResource(string ns, string name, ExtensionType extType, string ext, Arguments args, Application app, Type type, Version version, bool html) { for (int i = 0; i < args.Count; ++i) { name = string.Concat(name, '.', args[i]); } string query = app.Context.Request.Url.Query; if (!string.IsNullOrEmpty(query) && query.StartsWith("??")) { if (query.Length > 2) { string path; ResourceHandler handler = null; string[] array = query.Substring(2).Split(','); string[] names = new string[array.Length]; for (int i = 0; i < array.Length; ++i) { path = array[i]; if (i == 0) { UrlParse p = new UrlParse(path); handler = ResourceHandler.Parse(p.ExtensionType, p.Extension, false); if (handler == null) { app.RenderError(404); return; } } names[i] = FormatName(ns, string.Concat(name, '.', path)); } RenderResource(names, handler.ContentType, app, type, version); } else { app.RenderError(404); } } else { ResourceHandler hander = ResourceHandler.Parse(extType, ext, html); if (hander != null) { RenderResource(FormatName(ns, name), hander.ContentType, app, type, version); } else { app.RenderError(404); } } }