public void AddCommand(CommandInfo command) { foreach (string text in command.Aliases) { _root.AddCommand(_service, text, 0, command); } }
/// <exception cref="InvalidOperationException">Cannot add commands to the root node.</exception> public void AddCommand(CommandService service, string text, int index, CommandInfo command) { int nextSegment = NextSegment(text, index, service._separatorChar); string name; lock (_lockObj) { if (text == "") { if (_name == "") { throw new InvalidOperationException("Cannot add commands to the root node."); } _commands = _commands.Add(command); } else { if (nextSegment == -1) { name = text.Substring(index); } else { name = text.Substring(index, nextSegment - index); } string fullName = _name == "" ? name : _name + service._separatorChar + name; CommandMapNode nextNode = _nodes.GetOrAdd(name, x => new CommandMapNode(fullName)); nextNode.AddCommand(service, nextSegment == -1 ? "" : text, nextSegment + 1, command); } } }