private void RegisterIncludes(IEnumerable <BasicFile> files, ClientDependencyLoader loader, ClientDependencyType dependencyType) { foreach (var file in files) { loader.RegisterDependency(file.Group, file.Priority, file.FilePath, "", dependencyType, file.HtmlAttributes, file.ForceProvider); } }
private static void RegisterJsIncludes(string innerHtml, ClientDependencyLoader loader) { var tagPattern = string.Format(TagPattern, "script"); var typeAttributePattern = string.Format(AttributePattern, "type"); var srcAttributePattern = string.Format(AttributePattern, "src"); var count = 0; foreach (Match match in Regex.Matches(innerHtml, tagPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)) { var typeMatch = Regex.Match(match.Value, typeAttributePattern, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); if (typeMatch.Success && typeMatch.Groups["val"].Value == "text/javascript") { var srcMatch = Regex.Match(match.Value, srcAttributePattern, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); if (srcMatch.Success) { loader.RegisterDependency(Constants.DefaultPriority + count, srcMatch.Groups["val"].Value, ClientDependencyType.Javascript); count++; } } } }
protected override void OnInit(EventArgs e) { base.OnInit(e); var isNew = false; var loader = ClientDependencyLoader.TryCreate(Page, new HttpContextWrapper(Context), out isNew); RegisterIncludes(Text, loader); Text = string.Empty; }
/// <summary> /// Checks if a loader already exists, if it does, it returns it, otherwise it will /// create a new one in the control specified. /// isNew will be true if a loader was created, otherwise false if it already existed. /// </summary> /// <param name="parent"></param> /// <param name="http"></param> /// <param name="isNew"></param> /// <returns></returns> public static ClientDependencyLoader TryCreate(Control parent, HttpContextBase http, out bool isNew) { if (GetInstance(http) == null) { var loader = new ClientDependencyLoader(); parent.Controls.Add(loader); isNew = true; return(loader); } isNew = false; return(GetInstance(http)); }
private void RegisterIncludes(string innerHtml, ClientDependencyLoader loader) { RegisterIncludes(GetIncludes(innerHtml, ClientDependencyType.Css), loader, ClientDependencyType.Css); RegisterIncludes(GetIncludes(innerHtml, ClientDependencyType.Javascript), loader, ClientDependencyType.Javascript); }
private static void RegisterIncludes(string innerHtml, ClientDependencyLoader loader) { RegisterCssIncludes(innerHtml, loader); RegisterJsIncludes(innerHtml, loader); }