< Summary

Information
Class: MyNet.UI.Dialogs.ContentDialogs.DialogOptions
Assembly: MyNet.UI
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/Dialogs/ContentDialogs/DialogOptions.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 60
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Resolve(...)100%22100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/Dialogs/ContentDialogs/DialogOptions.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="DialogOptions.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7namespace MyNet.UI.Dialogs.ContentDialogs;
 8
 9/// <summary>
 10/// Represents the options for configuring a content dialog (modality, title, owner, overlay behaviour …).
 11/// </summary>
 12public sealed class DialogOptions
 13{
 14    /// <summary>
 15    /// Gets or sets the dialog associated with these options.
 16    /// </summary>
 17    public IDialog Dialog { get; set; } = null!;
 18
 19    /// <summary>
 20    /// Gets or sets a value indicating whether the dialog is modal.
 21    /// </summary>
 22    public bool IsModal { get; set; }
 23
 24    /// <summary>
 25    /// Gets or sets the title override for the dialog.
 26    /// When set, takes precedence over <see cref="IDialog.Title"/>.
 27    /// </summary>
 28    public string? Title { get; set; }
 29
 30    /// <summary>
 31    /// Gets or sets the owner of the dialog (e.g. the parent window).
 32    /// </summary>
 33    public object? Owner { get; set; }
 34
 35    /// <summary>
 36    /// Gets or sets a value indicating whether clicking on the overlay closes the dialog.
 37    /// Defaults to <see langword="true"/>.
 38    /// </summary>
 39    public bool CloseOnOverlayClick { get; set; } = true;
 40
 41    /// <summary>
 42    /// Creates a detached copy of <paramref name="options"/> bound to <paramref name="dialog"/>
 43    /// without mutating the caller's instance.
 44    /// </summary>
 45    /// <param name="dialog">The dialog instance to associate with the resolved options.</param>
 46    /// <param name="options">Optional source options; when <see langword="null"/>, defaults are used.</param>
 47    /// <returns>A new <see cref="DialogOptions"/> instance.</returns>
 48    public static DialogOptions Resolve(IDialog dialog, DialogOptions? options = null)
 3049        => options is null
 3050            ? new() { Dialog = dialog }
 3051            : new DialogOptions
 3052            {
 3053                Dialog = dialog,
 3054                IsModal = options.IsModal,
 3055                Title = options.Title,
 3056                Owner = options.Owner,
 3057                CloseOnOverlayClick = options.CloseOnOverlayClick
 3058            };
 59}
 60