예제 #1
0
        public string GetTabContent(TabType LoadType, string Path, IWebHostEnvironment physicalPath)

        {
            EJ2CoreSampleBrowser.Helpers.BrowserClasses.TagBuilder tabContent = new EJ2CoreSampleBrowser.Helpers.BrowserClasses.TagBuilder("div");
            string            Filestream = "";
            CSharpFormat      csformat   = new CSharpFormat();
            HtmlFormat        format     = new HtmlFormat();
            JavaScriptFormat  jsformat   = new JavaScriptFormat();
            VisualBasicFormat vbformat   = new VisualBasicFormat();

            switch (LoadType)
            {
            case TabType.Description:
                Filestream           = ReadTabContent(physicalPath.ContentRootPath + "\\" + Path);
                tabContent.InnerHtml = WebUtility.HtmlDecode(Filestream);
                break;

            case TabType.PartialView:
                Filestream           = ReadTabContent(physicalPath.ContentRootPath + "\\" + @"\Views" + Path.Replace("/", "\\"));
                tabContent.InnerHtml = format.FormatCode(Filestream).ToString();
                break;

            case TabType.View:
                Filestream           = ReadTabContent(physicalPath.ContentRootPath + "\\" + Path);
                tabContent.InnerHtml = format.FormatCode(Filestream).ToString();
                break;

            case TabType.VB:
            case TabType.CS:
                Filestream           = ReadTabContent(physicalPath.ContentRootPath + "\\" + Path);
                tabContent.InnerHtml = csformat.FormatCode(Filestream).ToString();
                break;

            case TabType.CSS:
                Filestream           = ReadTabContent(physicalPath.ContentRootPath + "\\" + Path);
                tabContent.InnerHtml = format.FormatCode(Filestream).ToString();
                break;

            case TabType.XML:
                Filestream           = ReadTabContent(@"/Models" + Path);
                tabContent.InnerHtml = csformat.FormatCode(Filestream).ToString();
                break;

            case TabType.JavaScript:
                Filestream           = ReadTabContent(physicalPath.ContentRootPath + "\\" + @"\Scripts" + Path.Replace("/", "\\"));
                tabContent.InnerHtml = jsformat.FormatCode(Filestream).ToString();
                break;

            case TabType.Model:
                Filestream           = ReadTabContent(@"/Models" + Path).ToString();
                tabContent.InnerHtml = csformat.FormatCode(Filestream).ToString();
                break;

            default:
                break;
            }

            return(tabContent.ToString());
        }
예제 #2
0
        public string GetTabContent(TabType LoadType, string Path)
        {
            TagBuilder        tabContent = new TagBuilder("div");
            string            Filestream = "";
            CSharpFormat      csformat   = new CSharpFormat();
            HtmlFormat        format     = new HtmlFormat();
            JavaScriptFormat  jsformat   = new JavaScriptFormat();
            VisualBasicFormat vbformat   = new VisualBasicFormat();
            HttpContext       context    = System.Web.HttpContext.Current;

            switch (LoadType)
            {
            case TabType.Description:
                Filestream           = ReadTabContent(context.Request.PhysicalApplicationPath + Path);
                tabContent.InnerHtml = context.Server.HtmlDecode(Filestream);
                break;

            case TabType.PartialView:
                Filestream           = ReadTabContent(context.Request.PhysicalApplicationPath + @"\Views" + Path.Replace("/", "\\"));
                tabContent.InnerHtml = format.FormatCode(Filestream).ToString();
                break;

            case TabType.View:
                Filestream           = ReadTabContent(context.Request.PhysicalApplicationPath + Path);
                tabContent.InnerHtml = format.FormatCode(Filestream).ToString();
                break;

            case TabType.VB:
            case TabType.CS:
                Filestream           = ReadTabContent(context.Request.PhysicalApplicationPath + Path);
                tabContent.InnerHtml = csformat.FormatCode(Filestream).ToString();
                break;

            case TabType.CSS:
                Filestream           = ReadTabContent(context.Request.PhysicalApplicationPath + Path);
                tabContent.InnerHtml = format.FormatCode(Filestream).ToString();
                break;

            case TabType.XML:
                Filestream           = ReadTabContent(@"/Models" + Path);
                tabContent.InnerHtml = csformat.FormatCode(Filestream).ToString();
                break;

            case TabType.JavaScript:
                Filestream           = ReadTabContent(context.Request.PhysicalApplicationPath + @"\Scripts" + Path.Replace("/", "\\"));
                tabContent.InnerHtml = jsformat.FormatCode(Filestream).ToString();
                break;

            case TabType.Model:
                Filestream           = ReadTabContent(@"/Models" + Path).ToString();
                tabContent.InnerHtml = csformat.FormatCode(Filestream).ToString();
                break;

            default:
                break;
            }

            return(tabContent.ToString());
        }
        public void ProcessRequest()
        {
            foreach (KeyValuePair <string, string> pair in TabInfo)
            {
                string filePath = pair.Value;
                if (File.Exists(filePath))
                {
                    FileInfo file = new FileInfo(filePath);
                    System.Web.UI.HtmlControls.HtmlGenericControl divelemt = new System.Web.UI.HtmlControls.HtmlGenericControl("Div");
                    divelemt.ClientIDMode = ClientIDMode.Static;
                    divelemt.ID           = Convert.ToString(pair.Key.Replace('.', '_'));
                    divelemt.Attributes.Add("Name", Convert.ToString(pair.Key));
                    switch (file.Extension.ToLower())
                    {
                    case ".cs":
                        CSharpFormat cformat = new CSharpFormat();
                        cformat.EmbedStyleSheet = false;
                        divelemt.InnerHtml      = cformat.FormatCode(new FileStream(file.FullName, FileMode.Open));
                        break;

                    case ".css":
                        HtmlFormat htmlformat = new HtmlFormat();
                        htmlformat.EmbedStyleSheet = false;
                        FileInfo files = file;
                        if (files.Length > 0)
                        {
                            string       s1 = "";
                            StreamReader reader1;
                            FileStream   stra;
                            stra               = new FileStream(files.FullName, FileMode.Open);
                            reader1            = new StreamReader(stra);
                            s1                 = s1 + ("<b><i>" + files.Name + "</i></b>");
                            s1                 = s1 + htmlformat.FormatCode(stra);
                            divelemt.InnerHtml = s1;
                        }

                        break;

                    case ".js":
                        JavaScriptFormat jsformat = new JavaScriptFormat();
                        jsformat.EmbedStyleSheet = false;
                        divelemt.InnerHtml       = jsformat.FormatCode(new FileStream(file.FullName, FileMode.Open));
                        break;

                    default:
                        HtmlFormat htmlformat5 = new HtmlFormat();
                        htmlformat5.EmbedStyleSheet = false;
                        divelemt.InnerHtml          = htmlformat5.FormatCode(new FileStream(file.FullName, FileMode.Open));
                        break;
                    }

                    this.Controls.Add(divelemt);
                }
            }
        }
예제 #4
0
    /// <summary>
    /// Returns the formatted text.
    /// </summary>
    /// <param name="options">Whatever options were set in the regex groups.</param>
    /// <param name="text">Send the e.body so it can get formatted.</param>
    /// <returns>The formatted string of the match.</returns>
    private string Highlight(HighlightOptions options, string text)
    {
        switch (options.Language)
        {
        case "c#":
            CSharpFormat csf = new CSharpFormat();
            csf.LineNumbers = options.DisplayLineNumbers;
            csf.Alternate   = options.AlternateLineNumbers;
            return(HttpContext.Current.Server.HtmlDecode(csf.FormatCode(text)));

        case "vb":
            VisualBasicFormat vbf = new VisualBasicFormat();
            vbf.LineNumbers = options.DisplayLineNumbers;
            vbf.Alternate   = options.AlternateLineNumbers;
            return(HttpContext.Current.Server.HtmlDecode(vbf.FormatCode(text)));

        case "js":
            JavaScriptFormat jsf = new JavaScriptFormat();
            jsf.LineNumbers = options.DisplayLineNumbers;
            jsf.Alternate   = options.AlternateLineNumbers;
            return(HttpContext.Current.Server.HtmlDecode(jsf.FormatCode(text)));

        case "html":
            HtmlFormat htmlf = new HtmlFormat();
            htmlf.LineNumbers = options.DisplayLineNumbers;
            htmlf.Alternate   = options.AlternateLineNumbers;
            text = StripHtml(text).Trim();
            string code = htmlf.FormatCode(HttpContext.Current.Server.HtmlDecode(text)).Trim();
            return(code.Replace("\r\n", "<br />").Replace("\n", "<br />"));

        case "xml":
            HtmlFormat xmlf = new HtmlFormat();
            xmlf.LineNumbers = options.DisplayLineNumbers;
            xmlf.Alternate   = options.AlternateLineNumbers;
            text             = text.Replace("<br />", "\r\n");
            text             = StripHtml(text).Trim();
            string xml = xmlf.FormatCode(HttpContext.Current.Server.HtmlDecode(text)).Trim();
            return(xml.Replace("\r\n", "<br />").Replace("\n", "<br />"));

        case "tsql":
            TsqlFormat tsqlf = new TsqlFormat();
            tsqlf.LineNumbers = options.DisplayLineNumbers;
            tsqlf.Alternate   = options.AlternateLineNumbers;
            return(HttpContext.Current.Server.HtmlDecode(tsqlf.FormatCode(text)));

        case "msh":
            MshFormat mshf = new MshFormat();
            mshf.LineNumbers = options.DisplayLineNumbers;
            mshf.Alternate   = options.AlternateLineNumbers;
            return(HttpContext.Current.Server.HtmlDecode(mshf.FormatCode(text)));
        }

        return(string.Empty);
    }
예제 #5
0
        /// <summary>
        /// Returns the formatted text.
        /// </summary>
        /// <param name="options">Whatever options were set in the regex groups.</param>
        /// <param name="text">Send the e.body so it can get formatted.</param>
        /// <returns>The formatted string of the match.</returns>
        private static string Highlight(HighlightOptions options, string text)
        {
            switch (options.Language)
            {
                case "c#":
                    var csf = new CSharpFormat();
                    csf.LineNumbers = options.DisplayLineNumbers;
                    csf.Alternate = options.AlternateLineNumbers;
                    return HttpUtility.HtmlDecode(csf.FormatCode(text));

                case "vb":
                    var vbf = new VisualBasicFormat();
                    vbf.LineNumbers = options.DisplayLineNumbers;
                    vbf.Alternate = options.AlternateLineNumbers;
                    return vbf.FormatCode(text);

                case "js":
                    var jsf = new JavaScriptFormat();
                    jsf.LineNumbers = options.DisplayLineNumbers;
                    jsf.Alternate = options.AlternateLineNumbers;
                    return HttpUtility.HtmlDecode(jsf.FormatCode(text));

                case "html":
                    var htmlf = new HtmlFormat();
                    htmlf.LineNumbers = options.DisplayLineNumbers;
                    htmlf.Alternate = options.AlternateLineNumbers;
                    text = StripHtml(text).Trim();
                    string code = htmlf.FormatCode(HttpUtility.HtmlDecode(text)).Trim();
                    return code.Replace("\r\n", "<br />").Replace("\n", "<br />");

                case "xml":
                    var xmlf = new HtmlFormat();
                    xmlf.LineNumbers = options.DisplayLineNumbers;
                    xmlf.Alternate = options.AlternateLineNumbers;
                    text = text.Replace("<br />", "\r\n");
                    text = StripHtml(text).Trim();
                    string xml = xmlf.FormatCode(HttpUtility.HtmlDecode(text)).Trim();
                    return xml.Replace("\r\n", "<br />").Replace("\n", "<br />");

                case "tsql":
                    var tsqlf = new TsqlFormat();
                    tsqlf.LineNumbers = options.DisplayLineNumbers;
                    tsqlf.Alternate = options.AlternateLineNumbers;
                    return HttpUtility.HtmlDecode(tsqlf.FormatCode(text));

                case "msh":
                    var mshf = new MshFormat();
                    mshf.LineNumbers = options.DisplayLineNumbers;
                    mshf.Alternate = options.AlternateLineNumbers;
                    return HttpUtility.HtmlDecode(mshf.FormatCode(text));

            }

            return string.Empty;
        }
예제 #6
0
    /// <summary>
    /// Returns the formatted text.
    /// </summary>
    /// <param name="options">
    /// Whatever options were set in the regex groups.
    /// </param>
    /// <param name="text">
    /// Send the e.body so it can get formatted.
    /// </param>
    /// <returns>
    /// The formatted string of the match.
    /// </returns>
    private static string Highlight(HighlightOptions options, string text)
    {
        switch (options.Language)
        {
        case "c#":
            var csf = new CSharpFormat
            {
                LineNumbers = options.DisplayLineNumbers,
                Alternate   = options.AlternateLineNumbers
            };
            return(HttpContext.Current.Server.HtmlDecode(csf.FormatCode(text)));

        case "vb":
            var vbf = new VisualBasicFormat
            {
                LineNumbers = options.DisplayLineNumbers,
                Alternate   = options.AlternateLineNumbers
            };
            return(HttpContext.Current.Server.HtmlDecode(vbf.FormatCode(text)));

        case "js":
            var jsf = new JavaScriptFormat
            {
                LineNumbers = options.DisplayLineNumbers,
                Alternate   = options.AlternateLineNumbers
            };
            return(HttpContext.Current.Server.HtmlDecode(jsf.FormatCode(text)));

        case "html":
            var htmlf = new HtmlFormat
            {
                LineNumbers = options.DisplayLineNumbers,
                Alternate   = options.AlternateLineNumbers
            };
            text = Utils.StripHtml(text);
            var code = htmlf.FormatCode(HttpContext.Current.Server.HtmlDecode(text)).Trim();
            return(code.Replace("\r\n", "<br />").Replace("\n", "<br />"));

        case "xml":
            var xmlf = new HtmlFormat
            {
                LineNumbers = options.DisplayLineNumbers,
                Alternate   = options.AlternateLineNumbers
            };
            text = text.Replace("<br />", "\r\n");
            text = Utils.StripHtml(text);
            var xml = xmlf.FormatCode(HttpContext.Current.Server.HtmlDecode(text)).Trim();
            return(xml.Replace("\r\n", "<br />").Replace("\n", "<br />"));

        case "tsql":
            var tsqlf = new TsqlFormat
            {
                LineNumbers = options.DisplayLineNumbers,
                Alternate   = options.AlternateLineNumbers
            };
            return(HttpContext.Current.Server.HtmlDecode(tsqlf.FormatCode(text)));

        case "msh":
            var mshf = new MshFormat
            {
                LineNumbers = options.DisplayLineNumbers,
                Alternate   = options.AlternateLineNumbers
            };
            return(HttpContext.Current.Server.HtmlDecode(mshf.FormatCode(text)));
        }

        return(string.Empty);
    }