public static bool ProcessKonsoleInput(string text) { string strCommand = text; string strArgument = ""; string[] strArgumentList = {}; string[] strtSplit = {}; try { strtSplit = text.Split(' '); if (strtSplit.Length >= 2) { strCommand = strtSplit[0]; ArrayList list = new ArrayList(); for (int i = 1; i < strtSplit.Length; ++i) { strArgument = strArgument + " " + strtSplit[i]; list.Add(strtSplit[i]); } strArgumentList = (string[])list.ToArray(typeof(string)); } KonsoleCommandEntry commandEntry = (KonsoleCommandEntry)m_KonsoleCMDs[strCommand]; if (commandEntry == null) { return(false); } else if (commandEntry.Handler != null) { commandEntry.Handler(new KonsoleCommandEventArgs(strCommand, strArgument, strArgumentList)); return(true); } } catch { throw new ArgumentException(); } return(false); }
public static void Register(string command, KonsoleCommandEventHandler handler) { m_KonsoleCMDs[command] = new KonsoleCommandEntry(command, handler); }