public void Initialize(string[] rootUrls, bool watchForChanges = true) { var bundleList = new List<Func<string>>(); foreach (var rootUrl in rootUrls) { var path = rootUrl; if (path.StartsWith("~/")) path = HostingEnvironment.MapPath(path); if (!Directory.Exists(path)) continue; foreach (var file in Directory.EnumerateFiles(path, "*.html", SearchOption.AllDirectories)) { var key = GetKey(file); if (key == null) continue; var script = new TemplateScript(key, () => File.ReadAllText(file)); DynamicScriptManager.Register(script); scriptByKey[key.ToLowerInvariant()] = script; bundleList.Add(script.GetScript); } if (watchForChanges) WatchForChanges(rootUrl); } bundle = new ConcatenatedScript(bundleList); DynamicScriptManager.Register("TemplateBundle", bundle); }
public void Initialize(string[] rootUrls, bool watchForChanges = true) { var bundleList = new List <Func <string> >(); foreach (var rootUrl in rootUrls) { var path = rootUrl; if (path.StartsWith("~/")) { path = HostingEnvironment.MapPath(path); } if (!path.EndsWith(Path.DirectorySeparatorChar.ToString())) { path = path + Path.DirectorySeparatorChar; } if (!Directory.Exists(path)) { continue; } foreach (var file in Directory.EnumerateFiles(path, "*.html", SearchOption.AllDirectories)) { var key = GetKey(path, file); if (key == null) { continue; } var script = new TemplateScript(key, () => File.ReadAllText(file)); DynamicScriptManager.Register(script); scriptByKey[key.ToLowerInvariant()] = script; bundleList.Add(script.GetScript); } if (watchForChanges) { WatchForChanges(path); } } bundle = new ConcatenatedScript(bundleList); DynamicScriptManager.Register("TemplateBundle", bundle); }
public void Initialize(string[] rootUrls, bool watchForChanges = true) { var bundleList = new List <Func <string> >(); foreach (var rootUrl in rootUrls) { var rootPath = HttpContext.Current.Server.MapPath(rootUrl); if (!Directory.Exists(rootPath)) { continue; } foreach (var file in Directory.EnumerateFiles(rootPath, "*.html", SearchOption.AllDirectories)) { var key = GetKey(file); if (key == null) { continue; } var script = new TemplateScript(key, () => File.ReadAllText(file)); DynamicScriptManager.Register(script); scriptByKey[key.ToLowerInvariant()] = script; bundleList.Add(script.GetScript); } if (watchForChanges) { WatchForChanges(rootUrl); } } bundle = new ConcatenatedScript(bundleList); DynamicScriptManager.Register("TemplateBundle", bundle); }