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); }