示例#1
0
        private static bool AddCommand(CCommand cmd)
        {
            string name = cmd.Name;

            for (LinkedListNode <CCommand> node = m_commands.First; node != null; node = node.Next)
            {
                CCommand otherCmd = node.Value;
                if (cmd == otherCmd)
                {
                    return(false); // no duplicates
                }

                string otherName = otherCmd.Name;
                int    compare   = name.CompareTo(otherName);
                if (compare < 0)
                {
                    m_commands.AddBefore(node, cmd);
                    m_commandsLookup.Add(cmd.Name, cmd);
                    return(true);
                }

                if (compare == 0)
                {
                    node.Value = cmd;
                    return(true);
                }
            }

            m_commands.AddLast(cmd);
            m_commandsLookup.Add(cmd.Name, cmd);

            return(true);
        }
示例#2
0
 public static void GetSuggested(string token, CommandList outList)
 {
     foreach (CCommand command in m_commands)
     {
         if (command.StartsWith(token))
         {
             outList.AddLast(command);
         }
     }
 }
示例#3
0
 public static void GetSuggested(string token, CommandList outList)
 {
     foreach (CCommand command in m_commands)
     {
         if (command.StartsWith(token))
         {
             outList.AddLast(command);
         }
     }
 }