⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parsevar.cs

📁 c#设计模式随书源码 c#设计模式随书源码
💻 CS
字号:
using System;
using System.Collections ;

namespace Interpreter
{
	/// <summary>
	/// Summary description for ParseVar.
	/// </summary>
	public class ParseVar: ParseObject {
		public const int FRNAME = 1;
		public const int LNAME = 2;
		public const int AGE = 3;
		public const int CLUB = 4;
		public const int TIME = 5;
		public const int tabMax = 5;
		//-----
		private static Hashtable hash, keyhash;
		
		//-----
		static  ParseVar() {
			hash = new Hashtable ();
			keyhash = new Hashtable ();
			hash.Add("frname", FRNAME);
			hash.Add ("lname", LNAME);
			hash.Add ("age", AGE);
			hash.Add ("club", CLUB);
			hash.Add ("time", TIME);		
			keyhash.Add(FRNAME, "frname");
			keyhash.Add (LNAME, "lname");
			keyhash.Add (AGE, "age");
			keyhash.Add (CLUB, "club");
			keyhash.Add (TIME, "time");		
		}
		//-------------
		static public string getTableName(int key) {
			return (string) keyhash[key];
		}
		//-----
		static public int computeValue(string s) {
			int v = 0;
			try {
				v =(int) hash[s];
				return v;
			}
			catch (NullReferenceException ) {
				v = -1;
				return v;
			}	
		} 
		//------
		public bool isLegal() {
			return value >= 0;
		}
		//----------
		public ParseVar(string s) :base(-1, VAR)	{
			value = ParseVar.computeValue (s.ToLower() );
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -