// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. namespace WixToolset.WixBA { using System; using System.Diagnostics; using System.Windows.Input; /// /// Base class that implements ICommand interface via delegates. /// public class RelayCommand : ICommand { private readonly Action execute; private readonly Predicate canExecute; public RelayCommand(Action execute) : this(execute, null) { } public RelayCommand(Action execute, Predicate canExecute) { this.execute = execute; this.canExecute = canExecute; } public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } [DebuggerStepThrough] public bool CanExecute(object parameter) { return this.canExecute == null ? true : this.canExecute(parameter); } public void Execute(object parameter) { this.execute(parameter); } } }