/// <summary>
        /// LoadFromRaw stylesheet data from the given source.<br/>
        /// The source can be local file or web URI.<br/>
        /// First raise <see cref="HtmlStylesheetLoadEventArgs"/> event to allow the client to overwrite the stylesheet loading.<br/>
        /// If the stylesheet is downloaded from URI we will try to correct local URIs to absolute.<br/>
        /// </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>
        /// <param name="stylesheet">return the stylesheet string that has been loaded (null if failed or <paramref name="stylesheetData"/> is given)</param>
        /// <param name="stylesheetData">return stylesheet data object that was provided by overwrite (null if failed or <paramref name="stylesheet"/> is given)</param>
        public static void LoadStylesheet(HtmlContainerInt htmlContainer, string src, Dictionary<string, string> attributes, out string stylesheet, out CssData stylesheetData)
        {
            ArgChecker.AssertArgNotNull(htmlContainer, "htmlContainer");

            stylesheet = null;
            stylesheetData = null;
            try
            {
                var args = new HtmlStylesheetLoadEventArgs(src, attributes);
                htmlContainer.RaiseHtmlStylesheetLoadEvent(args);

                if (!string.IsNullOrEmpty(args.SetStyleSheet))
                {
                    stylesheet = args.SetStyleSheet;
                }
                else if (args.SetStyleSheetData != null)
                {
                    stylesheetData = args.SetStyleSheetData;
                }
                else if (args.SetSrc != null)
                {
                    stylesheet = LoadStylesheet(htmlContainer, args.SetSrc);
                }
                else
                {
                    stylesheet = LoadStylesheet(htmlContainer, src);
                }
            }
            catch (Exception ex)
            {
                htmlContainer.ReportError(HtmlRenderErrorType.CssParsing, "Exception in handling stylesheet source", ex);
            }
        }
Ejemplo n.º 2
0
 private void OnStylesheetLoad(object sender, HtmlStylesheetLoadEventArgs e)
 {
     OnStylesheetLoad(e);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Propagate the stylesheet load event from root container.
 /// </summary>
 protected virtual void OnStylesheetLoad(HtmlStylesheetLoadEventArgs e)
 {
     var handler = StylesheetLoad;
     if (handler != null)
         handler(this, e);
 }
Ejemplo n.º 4
0
 /// <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);
     }
 }