< Summary

Information
Class: MyNet.UI.Commands.RelayCommandFactory
Assembly: MyNet.UI
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/Commands/RelayCommandFactory.cs
Tag: 323_28699572109
Line coverage
88%
Covered lines: 8
Uncovered lines: 1
Coverable lines: 9
Total lines: 49
Line coverage: 88.8%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
Create(...)100%11100%
Create(...)100%11100%
Create(...)100%11100%
Create(...)100%11100%
Create(...)100%11100%
Create(...)100%11100%
Create(...)100%210%
Create(...)100%11100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/Commands/RelayCommandFactory.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="RelayCommandFactory.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using System.Threading.Tasks;
 9using System.Windows.Input;
 10using MyNet.UI.Threading;
 11
 12namespace MyNet.UI.Commands;
 13
 14/// <summary>
 15/// A factory for creating RelayCommand and AsyncRelayCommand instances, optionally using a provided scheduler for comma
 16/// </summary>
 17/// <param name="schedulerProvider">The scheduler provider for UI thread scheduling.</param>
 18public class RelayCommandFactory(ISchedulerProvider? schedulerProvider = null) : ICommandFactory
 19{
 20    /// <summary>
 21    /// Gets a default instance of the <see cref="RelayCommandFactory"/> that uses the default scheduler provider.
 22    /// </summary>
 323    public static readonly RelayCommandFactory Default = new();
 24
 25    // <inheritdoc />
 18326    public ICommand Create(Action execute) => new RelayCommand(execute, schedulerProvider: schedulerProvider);
 27
 28    // <inheritdoc />
 59429    public ICommand Create(Action execute, Func<bool> canExecute) => new RelayCommand(execute, canExecute, schedulerProv
 30
 31    // <inheritdoc />
 13532    public ICommand Create<T>(Action<T?> execute) => new RelayCommand<T>(execute, schedulerProvider: schedulerProvider);
 33
 34    // <inheritdoc />
 13235    public ICommand Create<T>(Action<T?> execute, Func<T?, bool> canExecute) => new RelayCommand<T>(execute, canExecute,
 36
 37    // <inheritdoc />
 2738    public ICommand Create(Func<Task> execute) => new AsyncRelayCommand(execute, schedulerProvider: schedulerProvider);
 39
 40    // <inheritdoc />
 32441    public ICommand Create(Func<Task> execute, Func<bool> canExecute) => new AsyncRelayCommand(execute, canExecute, sche
 42
 43    // <inheritdoc />
 044    public ICommand Create<T>(Func<T?, Task> execute) => new AsyncRelayCommand<T>(execute, schedulerProvider: schedulerP
 45
 46    // <inheritdoc />
 4247    public ICommand Create<T>(Func<T?, Task> execute, Func<T?, bool> canExecute) => new AsyncRelayCommand<T>(execute, ca
 48}
 49