#pragma warning restore S2292 // Trivial properties should be auto-implemented internal Parser(Entity.Language language) //构造函数接受一个枚举变量 { string filename = ""; switch (language) //取得xml文件名 { case Entity.Language.CSharp: filename = "csharp.xml"; break; case Entity.Language.Java: filename = "jsharp.xml"; break; default: break; } StreamReader reader = new StreamReader(filename, System.Text.Encoding.UTF8 ); //下面的代码解析xml流 var xd = new XmlDocument(); xd.Load(reader); keyColor = new Hashtable(); XmlElement root = xd.DocumentElement; XmlNodeList xnl = root.SelectNodes("/definition/word"); for (int i = 0; i < xnl.Count; i++) { if (!keyColor.ContainsKey(xnl[i].ChildNodes[0].Value)) { keyColor.Add(xnl[i].ChildNodes[0].Value, new Entity.KeyCodeInfo { ColorStr = xnl[i].Attributes["color"].Value, Key = xnl[i].ChildNodes[0].Value, UseRegex = bool.Parse(xnl[i].Attributes["regex"].Value) }); } } //检测是否判断大小写 this.caseSensitive = bool.Parse(root.Attributes["caseSensitive"].Value); //检查颜色的值是否来源于RGB,否则按颜色名称 this.colorFromRGB = bool.Parse(root.Attributes["colorFromRGB"].Value); }
public static MvcHtmlString GetLanguageClass <TModel>(this HtmlHelper <TModel> self, Entity.Language Language) { string[] LanguageDisplay = { "c", "cpp", "cpp", "java", "pascal", "python", "python", "ruby", "csharp", "vbnet" }; var ret = LanguageDisplay[(int)Language]; return(new MvcHtmlString(ret)); }