/// <summary> /// Loads and embeds the content of an SVG file. /// </summary> /// <param name="html">A HtmlHelper that is the current HTML helper.</param> /// <param name="svgPath">A string indicating the virtual path to the file.</param> /// <param name="htmlAttributes">A dictionary with key string and value object that contains the HTML attributes to set for the element.</param> /// <returns>A MvcHtmlString containing the embedded SVG.</returns> public static MvcHtmlString EmbedSvg(this HtmlHelper html, string svgPath, IDictionary <string, object> htmlAttributes) { MvcHtmlString ReturnValue = MvcHtmlString.Empty; string SvgPath; SvgPath = HttpContext.Current.Server.MapPath(svgPath); if (File.Exists(SvgPath)) { TagBuilder ControlBuilder; string Content; Content = File.ReadAllText(SvgPath); ControlBuilder = HelperFunctions.GetTagBuilder(Content); ControlBuilder.MergeAttributes(htmlAttributes); ReturnValue = new MvcHtmlString(ControlBuilder.ToString()); } return(ReturnValue); }
/// <summary> /// Returns the Html of the control as string /// </summary> /// <typeparam name="TControl">Control</typeparam> /// <typeparam name="TBuilder">ControlBuilder</typeparam> /// <param name="target">ControlBuilder object</param> /// <returns>Html as string</returns> public static string ControlHtmlBuilder <TControl, TBuilder>(ControlBuilder <TControl, TBuilder> target) where TControl : Juime.Extensions.Control, new() where TBuilder : ControlBuilder <TControl, TBuilder> { return(target.ToString().StringReplace()); }