Command.Registry.Add C# (CSharp) Méthode

Add() public méthode

Registers the specified Command instance.
public Add ( Command cmd ) : void
cmd Command
Résultat void
        public void Add(Command cmd)
        {
            if(_commands.ContainsKey(cmd.Name)) {
                throw new ArgumentException(string.Format("A command has already been " +
                            "registered with the name {0} (in class {1})", cmd.Name, cmd.Type));
            }
            _commands.Add(cmd.Name, cmd);
            if(cmd.Alias != null) {
                if(!_commands.ContainsKey(cmd.Alias)) {
                    _commands.Add(cmd.Alias, cmd);
                }
                else {
                    _log.WarnFormat("Attempt to register command {0} under alias {1} failed; " +
                            "alias is already registered", cmd.Name, cmd.Alias);
                }
            }
        }

Same methods

Registry::Add ( Factory factory ) : void