//将领域命令中的验证错误信息收集 protected async Task NotifyValidationErrorsAsync(IntCommand message) { foreach (var error in message.ValidationResult.Errors) { //将错误信息提交到事件总线,派发出去 await Bus.RaiseEvent(new DomainNotification(DomainHandlerType.Validation, DomainNotificationType.Error, "", error.ErrorMessage)); } }
protected override void BeforeAwake() { BtnCommand = new ButtonCommand(BtnCommand_CanExecute, BtnCommand_Execute); TglCommand = new BoolCommand(TglCommand_CanExecute, TglCommand_Execute); SliderCommand = new FloatCommand(SliderCommand_CanExecute, SliderCommand_Execute); DropdownCommand = new IntCommand(DropdownCommand_CanExecute, DropdownCommand_Execute); InputCommand = new StringCommand(InputCommand_CanExecute, InputCommand_Execute); }
public void TestInt1() { var tokens = new List <Token> { P[PET.INT], P[PET.WordConst] }; var command = new IntCommand(tokens, OperandsSetType.I); runExpectedExceptionTest(command); }
public void TestInt0() { var tokens = new List <Token> { P[PET.INT], P[PET.ByteConst] }; var command = new IntCommand(tokens, OperandsSetType.I); runTest(command, new List <byte[]> { new byte[] { 0xCD, 0x64 } }); }
public static Command Create(string argname, TypeEnum type, string value) { switch (type) { case TypeEnum.String: return(StringCommand.Create(argname, value)); case TypeEnum.Int: return(IntCommand.Create(argname, value)); case TypeEnum.Bool: return(BooleanCommand.Create(argname, value)); default: // TODO: Handle not supported types throw new NotImplementedException(); } }
public static ICommand GenerateCommandWithLuaTable(LuaTable vmTable, LuaTable cmdLua) { XLuaCommandCanExecuteHandler commandCanExecute = cmdLua.Get <XLuaCommandCanExecuteHandler>("can_execute"); Func <object, bool> canExecuteDelegate = delegate(object parameter) { if (commandCanExecute == null) { return(true); } else { return(commandCanExecute.Invoke(vmTable, parameter)); } }; ICommand command = null; XLuaCommandType commandType = cmdLua.Get <XLuaCommandType>("type"); switch (commandType) { case XLuaCommandType.Void: XLuaCommandExecuteHandler commandExecute = cmdLua.Get <XLuaCommandExecuteHandler>("execute"); command = new VoidCommand( canExecuteDelegate, delegate(object parameter) { if (commandExecute != null) { commandExecute.Invoke(vmTable, parameter); } } ); break; case XLuaCommandType.Bool: XLuaCommandExecuteHandler <bool> boolCommandExecute = cmdLua.Get <XLuaCommandExecuteHandler <bool> >("execute"); command = new BoolCommand( canExecuteDelegate, delegate(bool v, object parameter) { if (boolCommandExecute != null) { boolCommandExecute.Invoke(vmTable, v, parameter); } } ); break; case XLuaCommandType.Float: XLuaCommandExecuteHandler <float> floatCommandExecute = cmdLua.Get <XLuaCommandExecuteHandler <float> >("execute"); command = new FloatCommand( canExecuteDelegate, delegate(float v, object parameter) { if (floatCommandExecute != null) { floatCommandExecute.Invoke(vmTable, v, parameter); } } ); break; case XLuaCommandType.Int: XLuaCommandExecuteHandler <int> intCommandExecute = cmdLua.Get <XLuaCommandExecuteHandler <int> >("execute"); command = new IntCommand( canExecuteDelegate, delegate(int v, object parameter) { if (intCommandExecute != null) { intCommandExecute.Invoke(vmTable, v, parameter); } } ); break; case XLuaCommandType.String: XLuaCommandExecuteHandler <string> stringCommandExecute = cmdLua.Get <XLuaCommandExecuteHandler <string> >("execute"); command = new StringCommand( canExecuteDelegate, delegate(string v, object parameter) { if (stringCommandExecute != null) { stringCommandExecute.Invoke(vmTable, v, parameter); } } ); break; case XLuaCommandType.Vector2: XLuaCommandExecuteHandler <Vector2> vector2CommandExecute = cmdLua.Get <XLuaCommandExecuteHandler <Vector2> >("execute"); command = new Vector2Command( canExecuteDelegate, delegate(Vector2 v, object parameter) { if (vector2CommandExecute != null) { vector2CommandExecute.Invoke(vmTable, v, parameter); } } ); break; } return(command); }