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(Action action, Func canExecute) => new(action, canExecute); public static RelayCommand CreateWithArg(Action action) => new(action); public static RelayCommand CreateConditionalWithArg(Action action, Predicate canExecute) => new(action, canExecute); public static AsyncRelayCommand CreateAsync(Func action) => new(action, AsyncRelayCommandOptions.None); public static AsyncRelayCommand CreateConcurrentAsync(Func action) => new(action, AsyncRelayCommandOptions.AllowConcurrentExecutions); public static AsyncRelayCommand CreateSilentFailAsync(Func action) => new(action, AsyncRelayCommandOptions.FlowExceptionsToTaskScheduler); public static AsyncRelayCommand CreateWithArgAsync(Func action) => new(action, AsyncRelayCommandOptions.None); public static AsyncRelayCommand CreateConcurrentWithArgAsync(Func action) => new(action, AsyncRelayCommandOptions.AllowConcurrentExecutions); public static AsyncRelayCommand CreateSilentFailWithArgAsync(Func action) => new(action, AsyncRelayCommandOptions.FlowExceptionsToTaskScheduler); public static AsyncRelayCommand CreateConditionalAsync(Func action, Func canExecute) => new(action, canExecute, AsyncRelayCommandOptions.None); public static AsyncRelayCommand CreateConcurrentConditionalAsync(Func action, Func canExecute) => new(action, canExecute, AsyncRelayCommandOptions.AllowConcurrentExecutions); public static AsyncRelayCommand CreateSilentFailConditionalAsync(Func action, Func canExecute) => new(action, canExecute, AsyncRelayCommandOptions.FlowExceptionsToTaskScheduler); public static AsyncRelayCommand CreateConditionalWithArgAsync(Func action, Predicate canExecute) => new(action, canExecute, AsyncRelayCommandOptions.None); public static AsyncRelayCommand CreateConcurrentConditionalWithArgAsync(Func action, Predicate canExecute) => new(action, canExecute, AsyncRelayCommandOptions.AllowConcurrentExecutions); public static AsyncRelayCommand CreateSilentFailConditionalWithArgAsync(Func action, Predicate canExecute) => new(action, canExecute, AsyncRelayCommandOptions.FlowExceptionsToTaskScheduler); } }