- tweak: refactor funny
This commit is contained in:
26
Nebula.Shared/Utils/DelegateCommand.cs
Normal file
26
Nebula.Shared/Utils/DelegateCommand.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Nebula.Shared.Utils;
|
||||
|
||||
public class DelegateCommand<T> : ICommand
|
||||
{
|
||||
private readonly Action<T> _func;
|
||||
public readonly Ref<T> TRef = new();
|
||||
|
||||
public DelegateCommand(Action<T> func)
|
||||
{
|
||||
_func = func;
|
||||
}
|
||||
|
||||
public bool CanExecute(object? parameter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Execute(object? parameter)
|
||||
{
|
||||
_func(TRef.Value);
|
||||
}
|
||||
|
||||
public event EventHandler? CanExecuteChanged;
|
||||
}
|
||||
Reference in New Issue
Block a user