public static void RegistryCommand(string commandKey, ICommandWithUndoRedo command) { if (string.IsNullOrEmpty(commandKey)) { throw new ArgumentNullException(nameof(commandKey)); } if (Commands.ContainsKey(commandKey)) { throw new ArgumentException($"Command {commandKey} already registered."); } Commands[commandKey] = command; }
public void Execute(object parameter = default) { Parameters = parameter.Cast <TParameter>(); Result = this._execute(Parameters, Result).Cast <TResult>(); ICommandWithUndoRedo.AddInUndo(this.Clone() as ICommandWithUndoRedo); ICommandWithUndoRedo.StackRedo.Clear(); Result = default(TResult); Parameters = default(TParameter); OnExecute?.Invoke(); }
void ICommandWithUndoRedo.UnExecute() { this._unExecute(Parameters, Result); ICommandWithUndoRedo.AddInRedo(this.Clone() as ICommandWithUndoRedo); }
void ICommandWithUndoRedo.ExecuteWithSubscribe() { this.Result = this._execute(this.Parameters, this.Result); ICommandWithUndoRedo.AddInUndo(this.Clone() as ICommandWithUndoRedo); }