Remotely/Desktop.Linux/Services/Executor.cs
2021-07-29 07:54:00 -07:00

40 lines
991 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace Remotely.Desktop.Linux.Services
{
public class Executor : ICommand
{
public Executor(Action<object> executeAction, Predicate<object> isExecutable = null)
{
ExecuteAction = executeAction;
IsExecutable = isExecutable;
}
#pragma warning disable
public event EventHandler CanExecuteChanged;
#pragma warning restore
private Action<object> ExecuteAction { get; set; }
private Predicate<object> IsExecutable { get; set; }
public bool CanExecute(object parameter)
{
if (IsExecutable == null)
{
return true;
}
return IsExecutable.Invoke(parameter);
}
public void Execute(object parameter)
{
ExecuteAction.Invoke(parameter);
}
}
}