以下是代码片段:
StringWriter textBuffer = new StringWriter();
Correspondência match= Regex.Match(HTMLStr,@"",RegexOptions.IgnoreCase | RegexOptions.Compiled);
if(correspondência==nulo)
{
Response.Write(HTMLStr);
retornar;
}
string codeType = match.Groups["codeType"].Value;
string content = match.Groups["codeContent"].Value;
if(codeType==String.Empty || content==String.Empty)
{
Response.Write(HTMLStr);
retornar;
}
//MessageBox.Show(codeType);
// MessageBox.Show(conteúdo);
string[] sr = content.Split(Convert.ToChar("n"));
if(codeType=="C#")
{
textBuffer.Write("<Csharp>rn");
foreach(string sourceLine em sr)
{
textBuffer.Write(FixCSLine(sourceLine)) ;
textBuffer.Write("rn");
}
textBuffer.Write("</Csharp>");
}
senão if(codeType=="JScript.Net")
{
textBuffer.Write("<JScript.Net>rn");
foreach(string sourceLine em sr)
{
textBuffer.Write(FixJSLine(sourceLine)) ;
textBuffer.Write("rn");
}
textBuffer.Write("</JScript.Net>");
}
senão if(codeType=="VB")
{
textBuffer.Write("<VB>rn");
foreach(string sourceLine em sr)
{
textBuffer.Write(FixVBLine(sourceLine)) ;
textBuffer.Write("rn");
}
textBuffer.Write("</VB>");
}