Example #1
0
        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;
        }
Example #2
0
        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();
        }
Example #3
0
        void ICommandWithUndoRedo.UnExecute()
        {
            this._unExecute(Parameters, Result);

            ICommandWithUndoRedo.AddInRedo(this.Clone() as ICommandWithUndoRedo);
        }
Example #4
0
        void ICommandWithUndoRedo.ExecuteWithSubscribe()
        {
            this.Result = this._execute(this.Parameters, this.Result);

            ICommandWithUndoRedo.AddInUndo(this.Clone() as ICommandWithUndoRedo);
        }