📄 stringparser.cs
字号:
// StringParser.cs
// Copyright (C) 2001 Mike Krueger
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using System;
using SharpDevelop.Tool.Data;
namespace SharpDevelop.Tool.Text {
/// <summary>
/// this class parses internal @ tags of sd.
/// </summary>
public class StringParser {
public static string Parse(string str)
{
return Parse(str, new string[,] {});
}
public static string Parse(string str, string[,] custom_tags)
{
string back = "";
for (int i = 0; i < str.Length; ++i) {
if (str[i] != '@')
back+= str[i];
else {
++i;
string token = "";
while (str[i] != '@')
token += str[i++];
switch (token.ToUpper()) {
case "":
back += "@";
break;
case "DATE": // current date
back += DateTime.Today.ToShortDateString();
break;
case "TIME": // current time
back += DateTime.Now.ToShortTimeString();
break;
default:
int k = token.IndexOf(':');
bool processcustom = true;
if (k > 0) {
processcustom = false;
switch (token.Substring(0, k).ToUpper()) {
case "RES":
back += Resource.GetString(token.Substring(k + 1));
break;
default:
processcustom = true;
break;
}
}
if (processcustom)
for (int j = 0; j < custom_tags.GetLength(0); ++j) {
if (token == custom_tags[j, 0].ToUpper()) {
back += custom_tags[j, 1].Replace(' ', '_').Replace('\t', '_');
break;
}
}
break;
}
}
}
return back;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -