forked from drewnoakes/string-theory
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDelegateCommand.cs
More file actions
35 lines (25 loc) · 928 Bytes
/
DelegateCommand.cs
File metadata and controls
35 lines (25 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Windows.Input;
namespace StringTheory.UI
{
internal sealed class DelegateCommand : ICommand
{
private readonly Action _execute;
public DelegateCommand(Action execute) => _execute = execute;
public bool CanExecute(object parameter) => true;
public void Execute(object parameter) => _execute();
#pragma warning disable CS0067
public event EventHandler CanExecuteChanged;
#pragma warning restore CS0067
}
internal sealed class DelegateCommand<T> : ICommand
{
private readonly Action<T> _execute;
public DelegateCommand(Action<T> execute) => _execute = execute;
public bool CanExecute(object parameter) => true;
public void Execute(object parameter) => _execute((T) parameter);
#pragma warning disable CS0067
public event EventHandler CanExecuteChanged;
#pragma warning restore CS0067
}
}