< Summary

Information
Class: Allyaria.Theming.StyleTypes.StyleTextDecorationLine
Assembly: Allyaria.Theming
File(s): /home/runner/work/allyaria/allyaria/src/Allyaria.Theming/StyleTypes/StyleTextDecorationLine.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 111
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Parse(...)100%22100%
TryParse(...)100%11100%
op_Implicit(...)100%11100%
op_Implicit(...)100%22100%

File(s)

/home/runner/work/allyaria/allyaria/src/Allyaria.Theming/StyleTypes/StyleTextDecorationLine.cs

#LineLine coverage
 1namespace Allyaria.Theming.StyleTypes;
 2
 3/// <summary>
 4/// Represents a CSS <c>text-decoration-line</c> value within the Allyaria theming system. Provides a strongly typed
 5/// wrapper for defining the decoration lines applied to text (e.g., underline, overline, line-through).
 6/// </summary>
 7public sealed record StyleTextDecorationLine : StyleValueBase
 8{
 9    /// <summary>
 10    /// Initializes a new instance of the <see cref="StyleTextDecorationLine" /> record using the specified <see cref="K
 11    /// value.
 12    /// </summary>
 13    /// <param name="kind">The text decoration line combination to represent.</param>
 14    public StyleTextDecorationLine(Kind kind)
 8815        : base(value: kind.GetDescription()) { }
 16
 17    /// <summary>
 18    /// Defines the supported CSS <c>text-decoration-line</c> property values. Multiple decorations can be represented b
 19    /// combining values.
 20    /// </summary>
 21    public enum Kind
 22    {
 23        /// <summary>Applies all standard text decorations: overline, line-through, and underline.</summary>
 24        [Description(description: "overline line-through underline")]
 25        All,
 26
 27        /// <summary>
 28        /// Draws a line through the middle of the text (commonly used to indicate deleted or discounted content).
 29        /// </summary>
 30        [Description(description: "line-through")]
 31        LineThrough,
 32
 33        /// <summary>Removes any text decorations from the element.</summary>
 34        [Description(description: "none")]
 35        None,
 36
 37        /// <summary>Draws a line above the text (overline).</summary>
 38        [Description(description: "overline")]
 39        Overline,
 40
 41        /// <summary>Draws both an overline and a line-through on the text.</summary>
 42        [Description(description: "overline line-through")]
 43        OverlineLineThrough,
 44
 45        /// <summary>Draws both an overline and an underline on the text.</summary>
 46        [Description(description: "overline underline")]
 47        OverlineUnderline,
 48
 49        /// <summary>Draws a line beneath the text (underline).</summary>
 50        [Description(description: "underline")]
 51        Underline,
 52
 53        /// <summary>Draws both an underline and a line-through on the text.</summary>
 54        [Description(description: "underline line-through")]
 55        UnderlineLineThrough
 56    }
 57
 58    /// <summary>
 59    /// Parses a string representation of a CSS <c>text-decoration-line</c> value into a <see cref="StyleTextDecorationL
 60    /// instance.
 61    /// </summary>
 62    /// <param name="value">The string representation of the text-decoration-line value.</param>
 63    /// <returns>A new <see cref="StyleTextDecorationLine" /> instance representing the parsed value.</returns>
 64    /// <exception cref="AryArgumentException">
 65    /// Thrown when the provided <paramref name="value" /> does not correspond to a valid <see cref="Kind" />.
 66    /// </exception>
 67    public static StyleTextDecorationLine Parse(string? value)
 1568        => value.TryParseEnum<Kind>(result: out var kind)
 1569            ? new StyleTextDecorationLine(kind: kind)
 1570            : throw new AryArgumentException(message: $"Invalid style: {value}", argName: nameof(value));
 71
 72    /// <summary>Attempts to parse a string into a <see cref="StyleTextDecorationLine" /> instance.</summary>
 73    /// <param name="value">The string representation of the text-decoration-line value to parse.</param>
 74    /// <param name="result">
 75    /// When this method returns, contains the parsed <see cref="StyleTextDecorationLine" /> instance or
 76    /// <see langword="null" /> if parsing failed.
 77    /// </param>
 78    /// <returns><see langword="true" /> if parsing succeeded; otherwise, <see langword="false" />.</returns>
 79    public static bool TryParse(string? value, out StyleTextDecorationLine? result)
 80    {
 81        try
 82        {
 383            result = Parse(value: value);
 84
 185            return true;
 86        }
 287        catch
 88        {
 289            result = null;
 90
 291            return false;
 92        }
 393    }
 94
 95    /// <summary>Implicitly converts a string into a <see cref="StyleTextDecorationLine" /> instance.</summary>
 96    /// <param name="value">The string representation of the text-decoration-line value.</param>
 97    /// <returns>A <see cref="StyleTextDecorationLine" /> instance representing the provided value.</returns>
 98    /// <exception cref="AryArgumentException">
 99    /// Thrown when the provided string cannot be parsed into a valid
 100    /// <see cref="Kind" />.
 101    /// </exception>
 2102    public static implicit operator StyleTextDecorationLine(string? value) => Parse(value: value);
 103
 104    /// <summary>Implicitly converts a <see cref="StyleTextDecorationLine" /> instance to its string representation.</su
 105    /// <param name="value">The <see cref="StyleTextDecorationLine" /> instance to convert.</param>
 106    /// <returns>
 107    /// The underlying CSS <c>text-decoration-line</c> string value, or an empty string if <paramref name="value" /> is
 108    /// <see langword="null" />.
 109    /// </returns>
 2110    public static implicit operator string(StyleTextDecorationLine? value) => (value?.Value).OrDefaultIfEmpty();
 111}