< Summary

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

#LineLine coverage
 1namespace Allyaria.Theming.StyleTypes;
 2
 3/// <summary>
 4/// Represents a CSS <c>text-overflow</c> value within the Allyaria theming system. Provides a strongly typed wrapper fo
 5/// defining how overflowing inline text is rendered when it exceeds its container.
 6/// </summary>
 7public sealed record StyleTextOverflow : StyleValueBase
 8{
 9    /// <summary>
 10    /// Initializes a new instance of the <see cref="StyleTextOverflow" /> record using the specified <see cref="Kind" /
 11    /// value.
 12    /// </summary>
 13    /// <param name="kind">The text overflow behavior to represent.</param>
 14    public StyleTextOverflow(Kind kind)
 1815        : base(value: kind.GetDescription()) { }
 16
 17    /// <summary>Defines the supported CSS <c>text-overflow</c> property values.</summary>
 18    public enum Kind
 19    {
 20        /// <summary>Clips overflowing text content without adding any visual indicator.</summary>
 21        [Description(description: "clip")]
 22        Clip,
 23
 24        /// <summary>Displays an ellipsis ("…") to represent clipped text when content overflows.</summary>
 25        [Description(description: "ellipsis")]
 26        Ellipsis
 27    }
 28
 29    /// <summary>
 30    /// Parses a string representation of a CSS <c>text-overflow</c> value into a <see cref="StyleTextOverflow" /> insta
 31    /// </summary>
 32    /// <param name="value">The string representation of the text-overflow value.</param>
 33    /// <returns>A new <see cref="StyleTextOverflow" /> instance representing the parsed value.</returns>
 34    /// <exception cref="AryArgumentException">
 35    /// Thrown when the provided <paramref name="value" /> does not correspond to a valid <see cref="Kind" />.
 36    /// </exception>
 37    public static StyleTextOverflow Parse(string? value)
 938        => value.TryParseEnum<Kind>(result: out var kind)
 939            ? new StyleTextOverflow(kind: kind)
 940            : throw new AryArgumentException(message: $"Invalid style: {value}", argName: nameof(value));
 41
 42    /// <summary>Attempts to parse a string into a <see cref="StyleTextOverflow" /> instance.</summary>
 43    /// <param name="value">The string representation of the text-overflow value to parse.</param>
 44    /// <param name="result">
 45    /// When this method returns, contains the parsed <see cref="StyleTextOverflow" /> instance or <see langword="null" 
 46    /// parsing failed.
 47    /// </param>
 48    /// <returns><see langword="true" /> if parsing succeeded; otherwise, <see langword="false" />.</returns>
 49    public static bool TryParse(string? value, out StyleTextOverflow? result)
 50    {
 51        try
 52        {
 353            result = Parse(value: value);
 54
 155            return true;
 56        }
 257        catch
 58        {
 259            result = null;
 60
 261            return false;
 62        }
 363    }
 64
 65    /// <summary>Implicitly converts a string into a <see cref="StyleTextOverflow" /> instance.</summary>
 66    /// <param name="value">The string representation of the text-overflow value.</param>
 67    /// <returns>A <see cref="StyleTextOverflow" /> instance representing the provided value.</returns>
 68    /// <exception cref="AryArgumentException">
 69    /// Thrown when the provided string cannot be parsed into a valid
 70    /// <see cref="Kind" />.
 71    /// </exception>
 272    public static implicit operator StyleTextOverflow(string? value) => Parse(value: value);
 73
 74    /// <summary>Implicitly converts a <see cref="StyleTextOverflow" /> instance to its string representation.</summary>
 75    /// <param name="value">The <see cref="StyleTextOverflow" /> instance to convert.</param>
 76    /// <returns>
 77    /// The underlying CSS <c>text-overflow</c> string value, or an empty string if <paramref name="value" /> is
 78    /// <see langword="null" />.
 79    /// </returns>
 280    public static implicit operator string(StyleTextOverflow? value) => (value?.Value).OrDefaultIfEmpty();
 81}