public void Configure(IConfiguration configuration, string path) { _traceFilter.ConfigureWith(configuration); _configurationRegistration = configuration.Register( path, cfg => { _configuration = cfg; Func <string, string> normalizeFolder = p => { p = p.Replace("/", "\\"); if (p.Length > 0 && !p.EndsWith("\\")) { p = p + "\\"; } return(_hostingEnvironment.MapPath(p)); }; Func <string, PathString> normalizeUrl = u => { u = u.Replace("\\", "/"); if (u.Length > 0 && u.EndsWith("/")) { u = u.Substring(0, u.Length - 1); } if (!u.StartsWith("/")) { u = "/" + u; } return(new PathString(u)); }; _rootFolder = normalizeFolder(cfg.RootDirectory ?? ""); _rootUrl = normalizeUrl(cfg.RootUrl ?? ""); }, new LessConfiguration()); }
private Task DocumentConfiguration(IOwinContext context) { var document = GetScriptResource("configuration.html"); document = document.Replace("{rootUrl}", _configuration.RootUrl); document = document.Replace("{documentationRootUrl}", _configuration.DocumentationRootUrl); document = document.Replace("{rootDirectory}", _configuration.RootDirectory); document = document.Replace("{enabled}", _configuration.Enabled.ToString()); document = document.Replace("{analyicsEnabled}", _configuration.AnalyticsEnabled.ToString()); var defaultConfiguration = new LessConfiguration(); document = document.Replace("{rootUrl.default}", defaultConfiguration.RootUrl); document = document.Replace("{documentationRootUrl.default}", defaultConfiguration.DocumentationRootUrl); document = document.Replace("{rootDirectory.default}", defaultConfiguration.RootDirectory); document = document.Replace("{enabled.default}", defaultConfiguration.Enabled.ToString()); document = document.Replace("{analyicsEnabled.default}", defaultConfiguration.AnalyticsEnabled.ToString()); context.Response.ContentType = "text/html"; return(context.Response.WriteAsync(document)); }