• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ColorCode.CodeColorizer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ColorCode.CodeColorizer的典型用法代码示例。如果您正苦于以下问题:C# CodeColorizer类的具体用法?C# CodeColorizer怎么用?C# CodeColorizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CodeColorizer类属于ColorCode命名空间,在下文中一共展示了CodeColorizer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SyntaxHighlight

        /// <summary>
        /// The syntax highlight.
        /// </summary>
        /// <param name="code">
        /// The code.
        /// </param>
        /// <param name="language">
        /// The language.
        /// </param>
        /// <returns>
        /// The System.String.
        /// </returns>
        private static string SyntaxHighlight(string code, string language)
        {
            CodeColorizer colorizer = new CodeColorizer();
            ILanguage lang = Languages.CSharp;
            switch (language)
            {
                case "C#":
                    lang = Languages.CSharp;
                    break;
                case "HTML":
                    lang = Languages.Html;
                    break;
                case "VB.NET":
                    lang = Languages.VbDotNet;
                    break;
                case "XML":
                    lang = Languages.Xml;
                    break;
                case "SQL":
                    lang = Languages.Sql;
                    break;
                case "JScript":
                    lang = Languages.JavaScript;
                    break;
            }

            return colorizer.Colorize(code, lang);
        }
开发者ID:pickup,项目名称:PickupBlog,代码行数:40,代码来源:SyntaxHighlighter.cs


示例2: Will_throw_if_the_style_sheet_is_null

            public void Will_throw_if_the_style_sheet_is_null()
            {
                CodeColorizer codeColorizer = new CodeColorizer(new StubLanguageParser());

                Exception ex = Record.Exception(() => codeColorizer.Colorize(string.Empty, new StubLanguage(), new StubFormatter(), null, new StubTextWriter()));

                Assert.IsType<ArgumentNullException>(ex);
                Assert.Equal("styleSheet", ((ArgumentNullException)ex).ParamName);
            }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:9,代码来源:CodeColorizerFacts.cs


示例3: WillColorizeASingleLineStyleComment

            public void WillColorizeASingleLineStyleComment()
            {
                const string source = @"//comment";
                var expected = AcceptanceHelper.BuildExpected(@"<span style=""color:Green;"">//comment</span>");

                var actual = new CodeColorizer().Colorize(source, Languages.Java);

                Assert.Equal(expected, actual);
            }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:9,代码来源:JavaAcceptanceTests.cs


示例4: WillColorizeAKeywordWithNoSurroundingText

            public void WillColorizeAKeywordWithNoSurroundingText(string keyword)
            {
                var source = keyword;
                var exepected = AcceptanceHelper.BuildExpected(@"<span style=""color:Blue;"">{0}</span>", keyword);

                var actual = new CodeColorizer().Colorize(source, Languages.Java);

                Assert.Equal(exepected, actual);
            }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:9,代码来源:JavaAcceptanceTests.cs


示例5: WillColorizeAKeywordWithPrecedingAndSucceedingText

            public void WillColorizeAKeywordWithPrecedingAndSucceedingText(string keyword)
            {
                var source = string.Format("fnord {0} fnord", keyword);
                var exepected = AcceptanceHelper.BuildExpected(@"fnord <span style=""color:Blue;"">{0}</span> fnord", keyword);

                var actual = new CodeColorizer().Colorize(source, Languages.Java);

                Assert.Equal(exepected, actual);
            }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:9,代码来源:JavaAcceptanceTests.cs


示例6: Will_throw_if_the_language_is_null_using_defaults_without_text_writer

            public void Will_throw_if_the_language_is_null_using_defaults_without_text_writer()
            {
                CodeColorizer codeColorizer = new CodeColorizer();

                Exception ex = Record.Exception(() => codeColorizer.Colorize(string.Empty, null));

                Assert.IsType<ArgumentNullException>(ex);
                Assert.Equal("language", ((ArgumentNullException)ex).ParamName);
            }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:9,代码来源:CodeColorizerFacts.cs


示例7: WillColorizeAMultieLineStyleCommentOnOneLine

            public void WillColorizeAMultieLineStyleCommentOnOneLine()
            {
                const string source = @"/*comment*/";
                var expected = AcceptanceHelper.BuildExpected(@"<span style=""color:Green;"">/*comment*/</span>");

                var actual = new CodeColorizer().Colorize(source, Languages.Cpp);

                Assert.Equal(expected, actual);
            }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:9,代码来源:CppAcceptanceTests.cs


示例8: TransformWillCommentMultipleCommentsCorrectly

        public void TransformWillCommentMultipleCommentsCorrectly()
        {
            string source = "<!-- test --><root><elment><!-- comment inside of element --></element></root>";
            string expected =
                "<div style=\"color:Black;background-color:White;\"><pre>\r\n<span style=\"color:Green;\">&lt;!-- test --&gt;</span><span style=\"color:Blue;\">&lt;</span><span style=\"color:#A31515;\">root</span><span style=\"color:Blue;\">&gt;</span><span style=\"color:Blue;\">&lt;</span><span style=\"color:#A31515;\">elment</span><span style=\"color:Blue;\">&gt;</span><span style=\"color:Green;\">&lt;!-- comment inside of element --&gt;</span><span style=\"color:Blue;\">&lt;/</span><span style=\"color:#A31515;\">element</span><span style=\"color:Blue;\">&gt;</span><span style=\"color:Blue;\">&lt;/</span><span style=\"color:#A31515;\">root</span><span style=\"color:Blue;\">&gt;</span>\r\n</pre></div>";

            string actual = new CodeColorizer().Colorize(source, Languages.Xml);

            Assert.Equal(expected, actual);
        }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:10,代码来源:XmlAcceptanceTests.cs


示例9: ColorCode_will_colorize_source_code

        public void ColorCode_will_colorize_source_code(string languageId, string sourceFileName, string expectedFileName)
        {
            ILanguage language = Languages.FindById(languageId);
            string sourceCode = File.ReadAllText(sourceFileName);
            string expectedHtml = File.ReadAllText(expectedFileName);

            string actualHtml = new CodeColorizer().Colorize(sourceCode, language);
            File.WriteAllText(expectedFileName.Replace(".expected.", ".actual."), actualHtml);

            Assert.Equal(expectedHtml, actualHtml);
        }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:11,代码来源:ColorizeTests.cs


示例10: GenericSampleView

 public GenericSampleView()
 {
     InitializeComponent();
     Loaded += (sender, args) =>
     {
         var code = (DataContext as ISample).Code;
         var html = new CodeColorizer().Colorize(code, Languages.CSharp);
         html = "<body style=\"background-color:#FFFFFF;\">" + html + "</body>";
         Browser.NavigateToString(html);
     };
 }
开发者ID:hispafox,项目名称:CMContrib,代码行数:11,代码来源:GenericSampleView.xaml.cs


示例11: Will_parse_the_source_code

            public void Will_parse_the_source_code()
            {
                StubLanguageParser stubLanguageParser = new StubLanguageParser();
                CodeColorizer codeColorizer = new CodeColorizer(stubLanguageParser);
                const string sourceCode = "fnord";
                StubLanguage stubLanguage = new StubLanguage();

                codeColorizer.Colorize(sourceCode, stubLanguage, new StubFormatter(), new StubStyleSheet(), new StubTextWriter());

                Assert.Equal(sourceCode, stubLanguageParser.Parse__sourceCode);
                Assert.Equal(stubLanguage, stubLanguageParser.Parse__language);
            }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:12,代码来源:CodeColorizerFacts.cs


示例12: TransformWillStyleDoubleQuotedString

        public void TransformWillStyleDoubleQuotedString()
        {
            string source =
            @"var variableName = ""aString"";";
            string expected =
            @"<div style=""color:Black;background-color:White;""><pre>
            <span style=""color:Blue;"">var</span> variableName = <span style=""color:#A31515;"">&quot;aString&quot;</span>;
            </pre></div>";

            string actual = new CodeColorizer().Colorize(source, Languages.JavaScript);

            Assert.Equal(expected, actual);
        }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:13,代码来源:JavaScriptAcceptanceTests.cs


示例13: TransformWillNotAddColorToDollarSignMethod

        public void TransformWillNotAddColorToDollarSignMethod()
        {
            string source =
            @"var variableName = $(""aString"");";
            string expected =
            @"<div style=""color:Black;background-color:White;""><pre>
            <span style=""color:Blue;"">var</span> variableName = $(<span style=""color:#A31515;"">&quot;aString&quot;</span>);
            </pre></div>";

            string actual = new CodeColorizer().Colorize(source, Languages.JavaScript);

            Assert.Equal(expected, actual);
        }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:13,代码来源:JavaScriptAcceptanceTests.cs


示例14: TransformWillStyleAddHandlerStatement

        public void TransformWillStyleAddHandlerStatement()
        {
            string source =
            @"AddHandler event, AddressOf eventHandler";
            string expected =
            @"<div style=""color:Black;background-color:White;""><pre>
            <span style=""color:Blue;"">AddHandler</span> <span style=""color:Blue;"">event</span>, <span style=""color:Blue;"">AddressOf</span> eventHandler
            </pre></div>";

            string actual = new CodeColorizer().Colorize(source, Languages.VbDotNet);

            Assert.Equal(expected, actual);
        }
开发者ID:cpancake,项目名称:ColorCode,代码行数:13,代码来源:VbDotNetAcceptanceTests.cs


示例15: TransformWillStylAnElementWithAttributes

        public void TransformWillStylAnElementWithAttributes()
        {
            string source =
            @"<anElement anAttribute=""anAttributeValue"" />";
            string expected =
            @"<div style=""color:Black;background-color:White;""><pre>
            <span style=""color:Blue;"">&lt;</span><span style=""color:#A31515;"">anElement</span> <span style=""color:Red;"">anAttribute</span><span style=""color:Blue;"">=</span><span style=""color:Blue;"">&quot;anAttributeValue&quot;</span> <span style=""color:Blue;"">/&gt;</span>
            </pre></div>";

            string actual = new CodeColorizer().Colorize(source, Languages.Html);

            Assert.Equal(expected, actual);
        }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:13,代码来源:HtmlAcceptanceTests.cs


示例16: TransformWillStyleASimpleElement

        public void TransformWillStyleASimpleElement()
        {
            string source =
            @"<html>";
            string expected =
            @"<div style=""color:Black;background-color:White;""><pre>
            <span style=""color:Blue;"">&lt;</span><span style=""color:#A31515;"">html</span><span style=""color:Blue;"">&gt;</span>
            </pre></div>";

            string actual = new CodeColorizer().Colorize(source, Languages.Html);

            Assert.Equal(expected, actual);
        }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:13,代码来源:HtmlAcceptanceTests.cs


示例17: TransformWillStyleAttributeWithUnderscore

        public void TransformWillStyleAttributeWithUnderscore()
        {
            string source =
            @"<elementName anAttribute_Name=""attributeValue"">&gt;</elementName>";
            string expected =
            @"<div style=""color:Black;background-color:White;""><pre>
            <span style=""color:Blue;"">&lt;</span><span style=""color:#A31515;"">elementName</span> <span style=""color:Red;"">anAttribute_Name</span><span style=""color:Blue;"">=</span><span style=""color:Blue;"">&quot;attributeValue&quot;</span><span style=""color:Blue;"">&gt;</span><span style=""color:Red;"">&amp;gt;</span><span style=""color:Blue;"">&lt;/</span><span style=""color:#A31515;"">elementName</span><span style=""color:Blue;"">&gt;</span>
            </pre></div>";

            string actual = new CodeColorizer().Colorize(source, Languages.Html);

            Assert.Equal(expected, actual);
        }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:13,代码来源:HtmlAcceptanceTests.cs


示例18: TransformWillStyleDivElement

        public void TransformWillStyleDivElement()
        {
            string source =
            @"<div id=""anId"">";
            string expected =
            @"<div style=""color:Black;background-color:White;""><pre>
            <span style=""color:Blue;"">&lt;</span><span style=""color:#A31515;"">div</span> <span style=""color:Red;"">id</span><span style=""color:Blue;"">=</span><span style=""color:Blue;"">&quot;anId&quot;</span><span style=""color:Blue;"">&gt;</span>
            </pre></div>";

            string actual = new CodeColorizer().Colorize(source, Languages.Html);

            Assert.Equal(expected, actual);
        }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:13,代码来源:HtmlAcceptanceTests.cs


示例19: TransformWillNotStyleObjectInSystemDotObject

        public void TransformWillNotStyleObjectInSystemDotObject()
        {
            string source =
            @"System.Object";
            string expected =
            @"<div style=""color:Black;background-color:White;""><pre>
            System.Object
            </pre></div>";

            string actual = new CodeColorizer().Colorize(source, Languages.VbDotNet);

            Assert.Equal(expected, actual);
        }
开发者ID:cpancake,项目名称:ColorCode,代码行数:13,代码来源:VbDotNetAcceptanceTests.cs


示例20: TransformWillNotStyleAssemblyKeywordInAttribute

        public void TransformWillNotStyleAssemblyKeywordInAttribute()
        {
            string source =
            @"<Assembly: CLSCompliant(True)>";
            string expected =
            @"<div style=""color:Black;background-color:White;""><pre>
            &lt;Assembly: CLSCompliant(<span style=""color:Blue;"">True</span>)&gt;
            </pre></div>";

            string actual = new CodeColorizer().Colorize(source, Languages.VbDotNet);

            Assert.Equal(expected, actual);
        }
开发者ID:cpancake,项目名称:ColorCode,代码行数:13,代码来源:VbDotNetAcceptanceTests.cs



注:本文中的ColorCode.CodeColorizer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ColorSpaces.Rgb类代码示例发布时间:2022-05-24
下一篇:
C# X86.Addr32类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap