public string getContent(IHostingEnvironment path) { ProductXmlDataEngine xmlEngine = new ProductXmlDataEngine(); TabType tabType = xmlEngine.GetTabType(this.FileName); string content = xmlEngine.GetTabContent(tabType, this.FileName, path); var copybutton = "<span class='copycode copycodedown'>COPY TO CLIPBOARD</span>"; string scriptTag = "<script>$(function(){initiateCopyHandler();});</script>"; return(content + copybutton + scriptTag); }
public static string RenderSourceCodeTab(this IHtmlHelper helper, string controlid) { HttpContextAccessor httpContextObj = new HttpContextAccessor(); ProductXmlDataEngine xmlEngine = new ProductXmlDataEngine(); HtmlTag wrapperDiv = new HtmlTag("div").Id(controlid); var urlHelper = new UrlHelper(helper.ViewContext); string sourcecodetabUrl = urlHelper.Action("Index", "SourceCodeTab"); wrapperDiv.Modify(w => { HtmlTag UlElement = new HtmlTag("ul", el => { el.Add(new HtmlTag("li", x => { string filePath = xmlEngine.GetSourceTabUrl(helper, TabType.View); x.Add("a").Text("View").Attributes().Add("href", sourcecodetabUrl + "?file=" + filePath); })); el.Add(new HtmlTag("li", x => { string filePath = xmlEngine.GetSourceTabUrl(helper, TabType.CS); x.Add("a").Text("Controller").Attributes().Add("href", sourcecodetabUrl + "?file=" + filePath); })); IEnumerable <XElement> otherFiles = xmlEngine.GetSourceCodeOtherFiles(helper); if (otherFiles != null) { foreach (var c in otherFiles) { el.Add(new HtmlTag("li", x => { x.Add(new HtmlTag("a").Text(c.Attribute("displayname").Value).Attributes("href", sourcecodetabUrl + "?file=" + c.Attribute("url").Value)); })); } } }); w.Add(UlElement); }); string scriptTag = "<script>$('#" + controlid + "').ejTab();</script>"; return(wrapperDiv.ToString() + scriptTag); }