コード例 #1
0
ファイル: CoreController.cs プロジェクト: EBassie/Potato
        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;
        }
コード例 #2
0
ファイル: CommandDispatch.cs プロジェクト: EBassie/Potato
 public bool CanDispatch(CommandAttributeType attributeType, ICommand command) {
     return this.CommandAttributeType == attributeType && this.Name == command.Name;
 }