/// <summary> /// Add command with a constrint object /// </summary> /// <param name="name"></param> /// <param name="constraint"></param> /// <returns></returns> public Commands Add(string name, CommandParamsConstraint constraint) { if (!_constraints.ContainsKey(name)) { _constraints.Add(name, constraint); } return(this); }
public Command(string name, Dictionary <string, CommandParamsConstraint> constraints, params string[] parameters) { _name = name; _params = parameters; if (constraints.ContainsKey(_name)) { CommandParamsConstraint constraint = constraints[_name]; if (constraint.Match(parameters)) { _parsed = constraint.Parsed; constraint.Action(this); } else { throw new CommandException(string.Format("Command '{0}' don't support these parameters", name)); } } else { throw new CommandException(string.Format("Command '{0}' is unknow", name)); } }