< Summary

Information
Class: MyNet.UI.ViewModels.Display.Options.DisplayColumnOptionViewModel
Assembly: MyNet.UI
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/ViewModels/Display/Options/DisplayColumnOptionViewModel.cs
Tag: 323_28699572109
Line coverage
82%
Covered lines: 19
Uncovered lines: 4
Coverable lines: 23
Total lines: 84
Line coverage: 82.6%
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%
set_CanBeHidden(...)100%11100%
set_IsVisible(...)100%11100%
set_Width(...)100%11100%
set_Order(...)100%11100%
Reset()100%210%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/ViewModels/Display/Options/DisplayColumnOptionViewModel.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="DisplayColumnOptionViewModel.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using MyNet.Observable;
 9
 10namespace MyNet.UI.ViewModels.Display.Options;
 11
 12/// <summary>
 13/// Represents one configurable column option for list display mode.
 14/// </summary>
 15public sealed class DisplayColumnOptionViewModel : ObservableObject
 16{
 17    private readonly bool _defaultIsVisible;
 18    private readonly string _defaultWidth;
 19    private readonly int _defaultOrder;
 20
 21    /// <summary>
 22    /// Initializes a new instance of the <see cref="DisplayColumnOptionViewModel"/> class.
 23    /// </summary>
 24    /// <param name="identifier">The unique column identifier.</param>
 25    /// <param name="canBeHidden">Whether the column can be hidden.</param>
 26    /// <param name="isVisible">Whether the column is initially visible.</param>
 27    /// <param name="width">The column width string.</param>
 28    /// <param name="order">The initial display order.</param>
 629    public DisplayColumnOptionViewModel(
 630        string identifier,
 631        bool canBeHidden = true,
 632        bool isVisible = true,
 633        string width = "*",
 634        int order = 0)
 35    {
 636        ArgumentException.ThrowIfNullOrWhiteSpace(identifier);
 37
 38        Identifier = identifier;
 639        CanBeHidden = canBeHidden;
 640        IsVisible = isVisible;
 641        Width = width;
 642        Order = order;
 43
 644        _defaultIsVisible = isVisible;
 645        _defaultWidth = width;
 646        _defaultOrder = order;
 647    }
 48
 49    /// <summary>
 50    /// Gets the unique column identifier.
 51    /// </summary>
 52    public string Identifier { get; }
 53
 54    /// <summary>
 55    /// Gets or sets a value indicating whether the column can be hidden.
 56    /// </summary>
 657    public bool CanBeHidden { get; set => SetProperty(ref field, value); }
 58
 59    /// <summary>
 60    /// Gets or sets a value indicating whether the column is visible.
 61    /// </summary>
 1262    public bool IsVisible { get; set => SetProperty(ref field, value); }
 63
 64    /// <summary>
 65    /// Gets or sets the column width.
 66    /// </summary>
 667    public string Width { get; set => SetProperty(ref field, value); }
 68
 69    /// <summary>
 70    /// Gets or sets the column display order.
 71    /// </summary>
 672    public int Order { get; set => SetProperty(ref field, value); }
 73
 74    /// <summary>
 75    /// Resets this column option to its default values.
 76    /// </summary>
 77    public void Reset()
 78    {
 079        IsVisible = _defaultIsVisible;
 080        Width = _defaultWidth;
 081        Order = _defaultOrder;
 082    }
 83}
 84