private ICommandResult Run(CommandAttributeType attributeType, ICommand command, CommandResultType maintainStatus) { // Loop through all matching commands with the identical name and type foreach (var dispatch in this.CommandDispatchers.Where(dispatch => dispatch.CanDispatch(attributeType, command))) { // Check if we can build a parameter list. Dictionary<String, ICommandParameter> parameters = dispatch.BuildParameterDictionary(command.Parameters); if (parameters != null) { command.Result = dispatch.Handler(command, parameters); // Our status has changed, break our loop. if (command.Result.CommandResultType != maintainStatus) { break; } } } return command.Result; }
public bool CanDispatch(CommandAttributeType attributeType, ICommand command) { return this.CommandAttributeType == attributeType && this.Name == command.Name; }