//------------------------------------------------------------------------------
//
// 此代码由工具生成。
// 运行时版本:2.0.50727.3082
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
//
//------------------------------------------------------------------------------
using System.Text.RegularExpressions;
using System.Resources;
namespace Sheng.Winform.Controls.Localisation {
///
///
///
public class Language {
private static ILanguage _Language;
private Language() {
}
///
/// Call GetLanguages() to retrieve a list of possible languages that can be used to set this property.
/// The default value is the default language.
///
public static ILanguage Current {
get {
if ((_Language == null)) {
//System.Collections.Generic.List list = Language.GetLanguages();
//for (int i = 0; (i < list.Count); i = (i + 1)) {
// if (list[i].IsDefault) {
// _Language = list[i];
// return _Language;
// }
//}
_Language = new Chinese__Simplified_();
}
return _Language;
}
set {
_Language = value;
}
}
///
/// Gets a list of available languages defined in this assembly.
///
public static System.Collections.Generic.List GetLanguages() {
System.Collections.Generic.List items = new System.Collections.Generic.List();
System.Type[] exportedTypes = System.Reflection.Assembly.GetExecutingAssembly().GetExportedTypes();
for (int i = 0; (i < exportedTypes.Length); i = (i + 1)) {
if (exportedTypes[i].IsClass) {
if ((exportedTypes[i].GetInterface("ILanguage") != null)) {
try {
object obj = System.Activator.CreateInstance(exportedTypes[i]);
ILanguage interfaceReference = ((ILanguage)(obj));
if ((interfaceReference != null)) {
items.Add(interfaceReference);
}
}
catch (System.Exception ) {
}
}
}
}
return items;
}
///
///
///
///
///
public static string GetString(string name)
{
return Current.ResourceManager.GetString(name);
}
//取${}花括号中间的字符串
readonly static Regex patternInner = new Regex(@"(?<=\${)([^\}]*)?(?=\})",
RegexOptions.Compiled | RegexOptions.CultureInvariant);
//取${}形式的完整字符串
readonly static Regex pattern = new Regex(@"\$\{[^\}]+\}",
RegexOptions.Compiled | RegexOptions.CultureInvariant);
///
/// 如果输入的字符串包含 "${...}" 这样的格式,则认为是指代资源文件中的一个字符串资源
///
///
///
public static string Parse(string input)
{
if (input == null)
{
return null;
}
string result = input;
string resString;
MatchCollection matchs = pattern.Matches(input);
foreach (Match match in matchs)
{
resString = GetString(patternInner.Match(match.Value).Value);
resString = resString.Replace("$NewLine$", System.Environment.NewLine);
result = result.Replace(match.Value, resString);
}
return result;
}
}
}