/// <summary> /// /// </summary> /// <param name="htmlContainer">the container of the html to handle load stylesheet for</param> /// <param name="src">the source of the element to load the stylesheet by</param> /// <param name="attributes">the attributes of the link element</param> public static string LoadStylesheet(HtmlContainer htmlContainer, string src, Dictionary<string, string> attributes) { ArgChecker.AssertArgNotNull(htmlContainer, "htmlContainer"); try { var args = new HtmlStylesheetLoadEventArgs(src, attributes); htmlContainer.RaiseHtmlStylesheetLoadEvent(args); if(args.SetStyleSheet != null) { return args.SetStyleSheet; } else if(args.SetSrc != null) { return LoadStylesheet(htmlContainer, args.SetSrc); } else { return LoadStylesheet(htmlContainer, src); } } catch (Exception ex) { htmlContainer.ReportError(HtmlRenderErrorType.CssParsing, "Exception in handling stylesheet source", ex); return string.Empty; } }
/// <summary> /// Raise the stylesheet load event with the given event args. /// </summary> /// <param name="args">the event args</param> internal void RaiseHtmlStylesheetLoadEvent(HtmlStylesheetLoadEventArgs args) { try { if (StylesheetLoad != null) { StylesheetLoad(this, args); } } catch (Exception ex) { ReportError(HtmlRenderErrorType.CssParsing, "Failed stylesheet load event", ex); } }
/// <summary> /// Propagate the stylesheet load event from root container. /// </summary> private void OnStylesheetLoad(object sender, HtmlStylesheetLoadEventArgs e) { if (StylesheetLoad != null) { StylesheetLoad(this, e); } }
/// <summary> /// Handle stylesheet resolve. /// </summary> private static void OnStylesheetLoad(object sender, HtmlStylesheetLoadEventArgs e) { var stylesheet = GetStylesheet(e.Src); if(stylesheet != null) e.SetStyleSheet = stylesheet; }