< Summary

Information
Class: Allyaria.Theming.StyleTypes.StyleTextDecorationStyle
Assembly: Allyaria.Theming
File(s): /home/runner/work/allyaria/allyaria/src/Allyaria.Theming/StyleTypes/StyleTextDecorationStyle.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 96
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/StyleTextDecorationStyle.cs

#LineLine coverage
 1namespace Allyaria.Theming.StyleTypes;
 2
 3/// <summary>
 4/// Represents a CSS <c>text-decoration-style</c> value within the Allyaria theming system. Provides a strongly typed
 5/// wrapper for defining the visual style of text decorations such as underlines or overlines.
 6/// </summary>
 7public sealed record StyleTextDecorationStyle : StyleValueBase
 8{
 9    /// <summary>
 10    /// Initializes a new instance of the <see cref="StyleTextDecorationStyle" /> record using the specified
 11    /// <see cref="Kind" /> value.
 12    /// </summary>
 13    /// <param name="kind">The decoration line style to represent.</param>
 14    public StyleTextDecorationStyle(Kind kind)
 7015        : base(value: kind.GetDescription()) { }
 16
 17    /// <summary>Defines the supported CSS <c>text-decoration-style</c> property values.</summary>
 18    public enum Kind
 19    {
 20        /// <summary>Draws the text decoration line as short dashes.</summary>
 21        [Description(description: "dashed")]
 22        Dashed,
 23
 24        /// <summary>Draws the text decoration line as a series of dots.</summary>
 25        [Description(description: "dotted")]
 26        Dotted,
 27
 28        /// <summary>Draws a pair of parallel lines for the text decoration.</summary>
 29        [Description(description: "double")]
 30        Double,
 31
 32        /// <summary>Draws a single solid line for the text decoration.</summary>
 33        [Description(description: "solid")]
 34        Solid,
 35
 36        /// <summary>Draws a wavy or zigzag line for the text decoration.</summary>
 37        [Description(description: "wavy")]
 38        Wavy
 39    }
 40
 41    /// <summary>
 42    /// Parses a string representation of a CSS <c>text-decoration-style</c> value into a
 43    /// <see cref="StyleTextDecorationStyle" /> instance.
 44    /// </summary>
 45    /// <param name="value">The string representation of the text-decoration-style value.</param>
 46    /// <returns>A new <see cref="StyleTextDecorationStyle" /> instance representing the parsed value.</returns>
 47    /// <exception cref="AryArgumentException">
 48    /// Thrown when the provided <paramref name="value" /> does not correspond to a valid <see cref="Kind" />.
 49    /// </exception>
 50    public static StyleTextDecorationStyle Parse(string? value)
 1251        => value.TryParseEnum<Kind>(result: out var kind)
 1252            ? new StyleTextDecorationStyle(kind: kind)
 1253            : throw new AryArgumentException(message: $"Invalid style: {value}", argName: nameof(value));
 54
 55    /// <summary>Attempts to parse a string into a <see cref="StyleTextDecorationStyle" /> instance.</summary>
 56    /// <param name="value">The string representation of the text-decoration-style value to parse.</param>
 57    /// <param name="result">
 58    /// When this method returns, contains the parsed <see cref="StyleTextDecorationStyle" /> instance or
 59    /// <see langword="null" /> if parsing failed.
 60    /// </param>
 61    /// <returns><see langword="true" /> if parsing succeeded; otherwise, <see langword="false" />.</returns>
 62    public static bool TryParse(string? value, out StyleTextDecorationStyle? result)
 63    {
 64        try
 65        {
 366            result = Parse(value: value);
 67
 168            return true;
 69        }
 270        catch
 71        {
 272            result = null;
 73
 274            return false;
 75        }
 376    }
 77
 78    /// <summary>Implicitly converts a string into a <see cref="StyleTextDecorationStyle" /> instance.</summary>
 79    /// <param name="value">The string representation of the text-decoration-style value.</param>
 80    /// <returns>A <see cref="StyleTextDecorationStyle" /> instance representing the provided value.</returns>
 81    /// <exception cref="AryArgumentException">
 82    /// Thrown when the provided string cannot be parsed into a valid
 83    /// <see cref="Kind" />.
 84    /// </exception>
 285    public static implicit operator StyleTextDecorationStyle(string? value) => Parse(value: value);
 86
 87    /// <summary>
 88    /// Implicitly converts a <see cref="StyleTextDecorationStyle" /> instance to its string representation.
 89    /// </summary>
 90    /// <param name="value">The <see cref="StyleTextDecorationStyle" /> instance to convert.</param>
 91    /// <returns>
 92    /// The underlying CSS <c>text-decoration-style</c> string value, or an empty string if <paramref name="value" /> is
 93    /// <see langword="null" />.
 94    /// </returns>
 295    public static implicit operator string(StyleTextDecorationStyle? value) => (value?.Value).OrDefaultIfEmpty();
 96}