using System; using System.Diagnostics; using YALV.Common.Interfaces; namespace YALV.Common { public class CommandRelay : ICommandAncestor { readonly protected Func _execute; readonly protected Predicate _canExecute; public CommandRelay(Func execute, Predicate canExecute) { _execute = execute; _canExecute = canExecute; } [DebuggerStepThrough] public bool CanExecute(object parameter) { return _canExecute == null ? true : _canExecute(parameter); } public event EventHandler CanExecuteChanged; [DebuggerStepThrough] public void Execute(object parameter) { _execute(parameter); } public void OnCanExecuteChanged() { if (null != CanExecuteChanged) CanExecuteChanged(this, EventArgs.Empty); } } }