using CommunityToolkit.Mvvm.Input; using System; using System.Threading.Tasks; namespace Ryujinx.Ava.UI.Helpers { #nullable enable public static class Commands { public static RelayCommand Create(Action action) => new(action); public static RelayCommand CreateConditional(Func canExecute, Action action) => new(action, canExecute); public static RelayCommand Create(Action action) => new(action); public static RelayCommand CreateConditional(Predicate canExecute, Action action) => new(action, canExecute); public static AsyncRelayCommand Create(Func action) => new(action, AsyncRelayCommandOptions.None); public static AsyncRelayCommand CreateConcurrent(Func action) => new(action, AsyncRelayCommandOptions.AllowConcurrentExecutions); public static AsyncRelayCommand CreateSilentFail(Func action) => new(action, AsyncRelayCommandOptions.FlowExceptionsToTaskScheduler); public static AsyncRelayCommand Create(Func action) => new(action, AsyncRelayCommandOptions.None); public static AsyncRelayCommand CreateConcurrent(Func action) => new(action, AsyncRelayCommandOptions.AllowConcurrentExecutions); public static AsyncRelayCommand CreateSilentFail(Func action) => new(action, AsyncRelayCommandOptions.FlowExceptionsToTaskScheduler); public static AsyncRelayCommand CreateConditional(Func canExecute, Func action) => new(action, canExecute, AsyncRelayCommandOptions.None); public static AsyncRelayCommand CreateConcurrentConditional(Func canExecute, Func action) => new(action, canExecute, AsyncRelayCommandOptions.AllowConcurrentExecutions); public static AsyncRelayCommand CreateSilentFailConditional(Func canExecute, Func action) => new(action, canExecute, AsyncRelayCommandOptions.FlowExceptionsToTaskScheduler); public static AsyncRelayCommand CreateConditional(Predicate canExecute, Func action) => new(action, canExecute, AsyncRelayCommandOptions.None); public static AsyncRelayCommand CreateConcurrentConditional(Predicate canExecute, Func action) => new(action, canExecute, AsyncRelayCommandOptions.AllowConcurrentExecutions); public static AsyncRelayCommand CreateSilentFailConditional(Predicate canExecute, Func action) => new(action, canExecute, AsyncRelayCommandOptions.FlowExceptionsToTaskScheduler); } }