< Summary

Information
Class: MyNet.UI.ViewModels.Shell.Drawers.ShellDrawerCoordinator
Assembly: MyNet.UI
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/ViewModels/Shell/Drawers/ShellDrawerCoordinator.cs
Tag: 323_28699572109
Line coverage
85%
Covered lines: 6
Uncovered lines: 1
Coverable lines: 7
Total lines: 36
Line coverage: 85.7%
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
.ctor(...)100%11100%
Dispose()100%210%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/ViewModels/Shell/Drawers/ShellDrawerCoordinator.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="ShellDrawerCoordinator.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using MyNet.UI.Dialogs.ContentDialogs;
 9
 10namespace MyNet.UI.ViewModels.Shell.Drawers;
 11
 12/// <summary>
 13/// Closes shell drawers when a content dialog opens (file dialogs are unaffected).
 14/// </summary>
 15public sealed class ShellDrawerCoordinator : IDisposable
 16{
 17    private readonly IContentDialogService _contentDialogService;
 18    private readonly EventHandler<ContentDialogLifecycleEventArgs> _dialogOpenedHandler;
 19
 20    /// <summary>
 21    /// Initializes a new instance of the <see cref="ShellDrawerCoordinator"/> class.
 22    /// </summary>
 23    public ShellDrawerCoordinator(IContentDialogService contentDialogService, IShellHostProvider hostProvider)
 24    {
 325        ArgumentNullException.ThrowIfNull(contentDialogService);
 326        ArgumentNullException.ThrowIfNull(hostProvider);
 27
 328        _contentDialogService = contentDialogService;
 329        _dialogOpenedHandler = (_, _) => hostProvider.Current?.CloseDrawers();
 330        _contentDialogService.DialogOpened += _dialogOpenedHandler;
 331    }
 32
 33    /// <inheritdoc />
 034    public void Dispose() => _contentDialogService.DialogOpened -= _dialogOpenedHandler;
 35}
 36