using System; using System.Collections.Generic; using System.Text; using System.Windows.Input; namespace ProxySU_Core.ViewModels { public class BaseCommand : ICommand { private readonly Action _execution; private readonly Func _canExecute; public BaseCommand(Action execution, Func canExecute = null) { _execution = execution; _canExecute = canExecute; } public event EventHandler CanExecuteChanged; public bool CanExecute(object parameter) { if (_canExecute == null) { return true; } return _canExecute(parameter); } public void Execute(object parameter) { if (_execution != null && CanExecute(parameter)) { _execution.Invoke(parameter); } } } }