当前位置: 首页>>代码示例>>C#>>正文


C# CodeColorizer类代码示例

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


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

示例1: WillStyleAMethodWithoutArguments

            public void WillStyleAMethodWithoutArguments()
            {
                string source =
                @"using System;

                namespace TheNamespace
                {
                /* This is a comment */
                public class TheClass
                : TheBaseClass, Implements
                {
                public string AMethod()
                {
                return ""Hello World!"";
                }
                }
                }";

                string expected =
                    "<div style=\"color:Black;background-color:White;\"><pre>\r\n<span style=\"color:Blue;\">using</span> System;\r\n\r\n<span style=\"color:Blue;\">namespace</span> TheNamespace\r\n{\r\n    <span style=\"color:Green;\">/* This is a comment */</span>\r\n    <span style=\"color:Blue;\">public</span> <span style=\"color:Blue;\">class</span> TheClass\r\n        : TheBaseClass, Implements\r\n    {\r\n        <span style=\"color:Blue;\">public</span> <span style=\"color:Blue;\">string</span> AMethod()\r\n        {\r\n            <span style=\"color:Blue;\">return</span> <span style=\"color:#A31515;\">&quot;Hello World!&quot;</span>;\r\n        }\r\n    }\r\n}\r\n</pre></div>";

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

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

示例2: WillStyleTextPtrFunction

            public void WillStyleTextPtrFunction()
            {
                string sourceText =
                @"USE pubs
                GO
                DECLARE @ptrval varbinary(16)
                SELECT @ptrval = TEXTPTR(logo)
                FROM pub_info pr, publishers p
                WHERE p.pub_id = pr.pub_id
                AND p.pub_name = 'New Moon Books'
                GO";
                string expected =
                @"<div style=""color:Black;background-color:White;""><pre>
                <span style=""color:Blue;"">USE</span> pubs
                GO
                <span style=""color:Blue;"">DECLARE</span> @ptrval <span style=""color:Blue;"">varbinary</span>(16)
                <span style=""color:Blue;"">SELECT</span> @ptrval = <span style=""color:Blue;"">TEXTPTR</span>(logo)
                <span style=""color:Blue;"">FROM</span> pub_info pr, publishers p
                <span style=""color:Blue;"">WHERE</span> p.pub_id = pr.pub_id
                <span style=""color:Blue;"">AND</span> p.pub_name = <span style=""color:#A31515;"">'New Moon Books'</span>
                GO
                </pre></div>";

                string actual = new CodeColorizer().Colorize(sourceText, Languages.Sql);

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

示例3: WillStyleElementsWithNamespace

            public void WillStyleElementsWithNamespace()
            {
                string source =
                @"<asp:DropDownList ID=""StateList"" runat=""server"">
                <asp:ListItem>CA</asp:ListItem>
                <asp:ListItem>IN</asp:ListItem>
                <asp:ListItem>KS</asp:ListItem>
                <asp:ListItem>MD</asp:ListItem>
                <asp:ListItem>MI</asp:ListItem>
                <asp:ListItem>OR</asp:ListItem>
                <asp:ListItem>TN</asp:ListItem>
                <asp:ListItem>UT</asp:ListItem>
                </asp:DropDownList>";
                string expected =
                @"<div style=""color:Black;background-color:White;""><pre>
                <span style=""color:Blue;"">&lt;</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">DropDownList</span> <span style=""color:Red;"">ID</span><span style=""color:Blue;"">=</span><span style=""color:Blue;"">&quot;StateList&quot;</span> <span style=""color:Red;"">runat</span><span style=""color:Blue;"">=</span><span style=""color:Blue;"">&quot;server&quot;</span><span style=""color:Blue;"">&gt;</span>
                <span style=""color:Blue;"">&lt;</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">&gt;</span>CA<span style=""color:Blue;"">&lt;/</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">&gt;</span>
                <span style=""color:Blue;"">&lt;</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">&gt;</span>IN<span style=""color:Blue;"">&lt;/</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">&gt;</span>
                <span style=""color:Blue;"">&lt;</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">&gt;</span>KS<span style=""color:Blue;"">&lt;/</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">&gt;</span>
                <span style=""color:Blue;"">&lt;</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">&gt;</span>MD<span style=""color:Blue;"">&lt;/</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">&gt;</span>
                <span style=""color:Blue;"">&lt;</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">&gt;</span>MI<span style=""color:Blue;"">&lt;/</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">&gt;</span>
                <span style=""color:Blue;"">&lt;</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">&gt;</span>OR<span style=""color:Blue;"">&lt;/</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">&gt;</span>
                <span style=""color:Blue;"">&lt;</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">&gt;</span>TN<span style=""color:Blue;"">&lt;/</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">&gt;</span>
                <span style=""color:Blue;"">&lt;</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">&gt;</span>UT<span style=""color:Blue;"">&lt;/</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">&gt;</span>
                <span style=""color:Blue;"">&lt;/</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">DropDownList</span><span style=""color:Blue;"">&gt;</span>
                </pre></div>";

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

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

示例4: WillStyleColLengthFunction

            public void WillStyleColLengthFunction()
            {
                string sourceText =
                @"USE AdventureWorks;
                GO
                CREATE TABLE t1
                (c1 varchar(40),
                c2 nvarchar(40)
                );
                GO
                SELECT COL_LENGTH('t1','c1')AS 'VarChar',
                COL_LENGTH('t1','c2')AS 'NVarChar';
                GO
                DROP TABLE t1;";
                string expected =
                @"<div style=""color:Black;background-color:White;""><pre>
                <span style=""color:Blue;"">USE</span> AdventureWorks;
                GO
                <span style=""color:Blue;"">CREATE</span> <span style=""color:Blue;"">TABLE</span> t1
                (c1 <span style=""color:Blue;"">varchar</span>(40),
                c2 <span style=""color:Blue;"">nvarchar</span>(40)
                );
                GO
                <span style=""color:Blue;"">SELECT</span> <span style=""color:Blue;"">COL_LENGTH</span>(<span style=""color:#A31515;"">'t1'</span>,<span style=""color:#A31515;"">'c1'</span>)<span style=""color:Blue;"">AS</span> <span style=""color:#A31515;"">'VarChar'</span>,
                <span style=""color:Blue;"">COL_LENGTH</span>(<span style=""color:#A31515;"">'t1'</span>,<span style=""color:#A31515;"">'c2'</span>)<span style=""color:Blue;"">AS</span> <span style=""color:#A31515;"">'NVarChar'</span>;
                GO
                <span style=""color:Blue;"">DROP</span> <span style=""color:Blue;"">TABLE</span> t1;
                </pre></div>";

                string actual = new CodeColorizer().Colorize(sourceText, Languages.Sql);

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

示例5: WillStyleKnownAttributeTargets

            public void WillStyleKnownAttributeTargets()
            {
                string source =
                @"[assembly: SomeAttribute]
                [module: SomeAttribute]
                [type: SomeAttribute]
                [return: SomeAttribute]
                [param: SomeAttribute]
                [method: SomeAttribute]
                [field: SomeAttribute]
                [property: SomeAttribute]
                [event: SomeAttribute]";
                string expected =
                @"<div style=""color:Black;background-color:White;""><pre>
                [<span style=""color:Blue;"">assembly</span>: SomeAttribute]
                [<span style=""color:Blue;"">module</span>: SomeAttribute]
                [<span style=""color:Blue;"">type</span>: SomeAttribute]
                [<span style=""color:Blue;"">return</span>: SomeAttribute]
                [<span style=""color:Blue;"">param</span>: SomeAttribute]
                [<span style=""color:Blue;"">method</span>: SomeAttribute]
                [<span style=""color:Blue;"">field</span>: SomeAttribute]
                [<span style=""color:Blue;"">property</span>: SomeAttribute]
                [<span style=""color:Blue;"">event</span>: SomeAttribute]
                </pre></div>";

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

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

示例6: WillStyleHeaderWithKeywords

        public void WillStyleHeaderWithKeywords()
        {
            string source = @"<%@ Application Language=""C#"" CodeBehind=""Global.asax.cs"" Inherits=""Microsoft.Foundation.Web.Global"" %><script runat=""server"">bool public false</script>";
            string expected = "<div style=\"color:Black;background-color:White;\"><pre>\r\n<span style=\"background-color:Yellow;\">&lt;%</span><span style=\"color:Blue;\">@</span> <span style=\"color:#A31515;\">Application</span> <span style=\"color:Red;\">Language</span><span style=\"color:Blue;\">=</span><span style=\"color:Blue;\">&quot;C#&quot;</span> <span style=\"color:Red;\">CodeBehind</span><span style=\"color:Blue;\">=</span><span style=\"color:Blue;\">&quot;Global.asax.cs&quot;</span> <span style=\"color:Red;\">Inherits</span><span style=\"color:Blue;\">=</span><span style=\"color:Blue;\">&quot;Microsoft.Foundation.Web.Global&quot;</span> <span style=\"background-color:Yellow;\">%&gt;</span><span style=\"color:Blue;\">&lt;</span><span style=\"color:#A31515;\">script</span> <span style=\"color:Red;\">runat</span><span style=\"color:Blue;\">=</span><span style=\"color:Blue;\">&quot;server&quot;</span><span style=\"color:Blue;\">&gt;</span><span style=\"color:Blue;\">bool</span> <span style=\"color:Blue;\">public</span> <span style=\"color:Blue;\">false</span><span style=\"color:Blue;\">&lt;/</span><span style=\"color:#A31515;\">script</span><span style=\"color:Blue;\">&gt;</span>\r\n</pre></div>";

            string actual = new CodeColorizer().Colorize(source, GetGrammar());
            Assert.Equal(expected, actual);
        }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:8,代码来源:AsaxAcceptanceTests.cs

示例7: WillNotStyleKeyword

            public void WillNotStyleKeyword()
            {
                string source = "get bool false";
                string expected = "<div style=\"color:Black;background-color:White;\"><pre>\r\nget bool false\r\n</pre></div>";

                string actual = new CodeColorizer().Colorize(source, GetGrammar());
                Assert.Equal(expected, actual);
            }
开发者ID:RichardSlater,项目名称:ColorCodePortable,代码行数:8,代码来源:AshxAcceptanceTests.cs

示例8: TransformWillStyleAttributeTarget

            public void TransformWillStyleAttributeTarget()
            {
                string source =
                @"[assembly: SomeAttribute]";
                string expected =
                @"<div style=""color:Black;background-color:White;""><pre>
                [<span style=""color:Blue;"">assembly</span>: SomeAttribute]
                </pre></div>";

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

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

示例9: WillNotStyleKeywordsPrecededByAtSign

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

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

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

示例10: WillNotStyleKeywordInsideStraightBracesWithSpaceBeforeAndAfter

            public void WillNotStyleKeywordInsideStraightBracesWithSpaceBeforeAndAfter()
            {
                string source =
                @"[ SELECT ]";
                string expected =
                @"<div style=""color:Black;background-color:White;""><pre>
                [ SELECT ]
                </pre></div>";

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

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

示例11: GetColorizer

        public CodeColorizer GetColorizer( string key )
        {
            if (SyntaxEngine == null)
            {
                lock(SyntaxEngine)
                {
                    SyntaxEngine = config.Configure();
                    if (SyntaxEngine == null)
                        throw (new Exception("Could not create colorizer engine"));
                }
            }

            return SyntaxEngine;
        }
开发者ID:vanzheng,项目名称:CShareCodeSample,代码行数:14,代码来源:SingleInstanceRepository.cs

示例12: WillStyleASolitaryUsingStatement

            public void WillStyleASolitaryUsingStatement()
            {
                string source =
                @"using System;";

                string expected =
                @"<div style=""color:Black;background-color:White;""><pre>
                <span style=""color:Blue;"">using</span> System;
                </pre></div>";

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

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

示例13: WillStyleDoctypeWithLineBreakInDoubleQuotedString

            public void WillStyleDoctypeWithLineBreakInDoubleQuotedString()
            {
                string source =
                @"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML
                1.1//EN"" ""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"">";
                string expected =
                @"<div style=""color:Black;background-color:White;""><pre>
                <span style=""color:Blue;"">&lt;!</span><span style=""color:#A31515;"">DOCTYPE</span> <span style=""color:Red;"">html</span> <span style=""color:Red;"">PUBLIC</span> <span style=""color:Blue;"">&quot;-//W3C//DTD XHTML
                1.1//EN&quot;</span> <span style=""color:Blue;"">&quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;</span><span style=""color:Blue;"">&gt;</span>
                </pre></div>";

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

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

示例14: TransformWillStyleClassName

            public void TransformWillStyleClassName()
            {
                string source =
                @"public class ClassName
                {";
                string expected =
                @"<div style=""color:Black;background-color:White;""><pre>
                <span style=""color:Blue;"">public</span> <span style=""color:Blue;"">class</span> ClassName
                {
                </pre></div>";

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

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

示例15: WillStyleAlterAssembly

            public void WillStyleAlterAssembly()
            {
                string sourceText =
                    @"ALTER ASSEMBLY MyClass
                ADD FILE FROM 'C:\MyClassProject\Class1.cs';";
                string expected =
                    @"<div style=""color:Black;background-color:White;""><pre>
                <span style=""color:Blue;"">ALTER</span> <span style=""color:Blue;"">ASSEMBLY</span> MyClass
                <span style=""color:Blue;"">ADD</span> <span style=""color:Blue;"">FILE</span> <span style=""color:Blue;"">FROM</span> <span style=""color:#A31515;"">'C:\MyClassProject\Class1.cs'</span>;
                </pre></div>";

                string actual = new CodeColorizer().Colorize(sourceText, Languages.Sql);

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


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