本文整理汇总了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;\">"Hello World!"</span>;\r\n }\r\n }\r\n}\r\n</pre></div>";
string actual = new CodeColorizer().Colorize(source, Languages.CSharp);
Assert.Equal(expected, actual);
}
示例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);
}
示例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;""><</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;"">"StateList"</span> <span style=""color:Red;"">runat</span><span style=""color:Blue;"">=</span><span style=""color:Blue;"">"server"</span><span style=""color:Blue;"">></span>
<span style=""color:Blue;""><</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">></span>CA<span style=""color:Blue;""></</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">></span>
<span style=""color:Blue;""><</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">></span>IN<span style=""color:Blue;""></</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">></span>
<span style=""color:Blue;""><</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">></span>KS<span style=""color:Blue;""></</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">></span>
<span style=""color:Blue;""><</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">></span>MD<span style=""color:Blue;""></</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">></span>
<span style=""color:Blue;""><</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">></span>MI<span style=""color:Blue;""></</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">></span>
<span style=""color:Blue;""><</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">></span>OR<span style=""color:Blue;""></</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">></span>
<span style=""color:Blue;""><</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">></span>TN<span style=""color:Blue;""></</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">></span>
<span style=""color:Blue;""><</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">></span>UT<span style=""color:Blue;""></</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">ListItem</span><span style=""color:Blue;"">></span>
<span style=""color:Blue;""></</span><span style=""color:#A31515;"">asp</span><span style=""color:Blue;"">:</span><span style=""color:#A31515;"">DropDownList</span><span style=""color:Blue;"">></span>
</pre></div>";
string actual = new CodeColorizer().Colorize(source, GetGrammar());
Assert.Equal(expected, actual);
}
示例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);
}
示例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);
}
示例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;\"><%</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;\">"C#"</span> <span style=\"color:Red;\">CodeBehind</span><span style=\"color:Blue;\">=</span><span style=\"color:Blue;\">"Global.asax.cs"</span> <span style=\"color:Red;\">Inherits</span><span style=\"color:Blue;\">=</span><span style=\"color:Blue;\">"Microsoft.Foundation.Web.Global"</span> <span style=\"background-color:Yellow;\">%></span><span style=\"color:Blue;\"><</span><span style=\"color:#A31515;\">script</span> <span style=\"color:Red;\">runat</span><span style=\"color:Blue;\">=</span><span style=\"color:Blue;\">"server"</span><span style=\"color:Blue;\">></span><span style=\"color:Blue;\">bool</span> <span style=\"color:Blue;\">public</span> <span style=\"color:Blue;\">false</span><span style=\"color:Blue;\"></</span><span style=\"color:#A31515;\">script</span><span style=\"color:Blue;\">></span>\r\n</pre></div>";
string actual = new CodeColorizer().Colorize(source, GetGrammar());
Assert.Equal(expected, actual);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;""><!</span><span style=""color:#A31515;"">DOCTYPE</span> <span style=""color:Red;"">html</span> <span style=""color:Red;"">PUBLIC</span> <span style=""color:Blue;"">"-//W3C//DTD XHTML
1.1//EN"</span> <span style=""color:Blue;"">"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"</span><span style=""color:Blue;"">></span>
</pre></div>";
string actual = new CodeColorizer().Colorize(source, GetGrammar());
Assert.Equal(expected, actual);
}
示例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);
}
示例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);
}