示例#1
0
        private AbstractCommand GetCommand(string key)
        {
            AbstractCommand command = null;

            chain.TryGetValue(key, out command);
            return(command);
        }
示例#2
0
        public void AddCommand(AbstractCommand command)
        {
            string key = command.GetKey();

            if (chain.ContainsKey(key))
            {
                return;
            }
            else
            {
                chain.Add(key, command);
            }
        }
示例#3
0
 private void GetHelp(string param = "")
 {
     if (param == "")
     {
         foreach (var item in chain)
         {
             Console.WriteLine(item.Value.GetHelp());
         }
     }
     else
     {
         AbstractCommand command = null;
         if (chain.TryGetValue(param, out command))
         {
             Console.WriteLine(command.GetHelp());
         }
     }
 }
示例#4
0
        internal void Excute(Parameter parameter)
        {
            AbstractCommand command = GetCommand(parameter.Key);

            if (command == null)
            {
                string strParam = "";
                if (parameter.Key == "help")
                {
                    if (parameter.ParamList.Count > 0)
                    {
                        strParam = parameter.ParamList[0];
                    }
                }
                GetHelp(strParam);
                return;
            }
            command.Excute(parameter);
        }