< Summary

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

#LineLine coverage
 1namespace Allyaria.Theming.StyleTypes;
 2
 3/// <summary>
 4/// Represents a CSS <c>text-orientation</c> value within the Allyaria theming system. Provides a strongly typed wrapper
 5/// for defining the orientation of text characters in vertical writing modes.
 6/// </summary>
 7public sealed record StyleTextOrientation : StyleValueBase
 8{
 9    /// <summary>
 10    /// Initializes a new instance of the <see cref="StyleTextOrientation" /> record using the specified <see cref="Kind
 11    /// value.
 12    /// </summary>
 13    /// <param name="kind">The text orientation type to represent.</param>
 14    public StyleTextOrientation(Kind kind)
 2415        : base(value: kind.GetDescription()) { }
 16
 17    /// <summary>Defines the supported CSS <c>text-orientation</c> property values.</summary>
 18    public enum Kind
 19    {
 20        /// <summary>
 21        /// Uses mixed orientation for characters: upright for ideographic and vertical forms, sideways for others such 
 22        /// characters.
 23        /// </summary>
 24        [Description(description: "mixed")]
 25        Mixed,
 26
 27        /// <summary>Rotates all characters sideways, as if in horizontal layout, within a vertical writing mode.</summa
 28        [Description(description: "sideways")]
 29        Sideways,
 30
 31        /// <summary>Displays all characters upright within a vertical writing mode.</summary>
 32        [Description(description: "upright")]
 33        Upright
 34    }
 35
 36    /// <summary>
 37    /// Parses a string representation of a CSS <c>text-orientation</c> value into a <see cref="StyleTextOrientation" />
 38    /// instance.
 39    /// </summary>
 40    /// <param name="value">The string representation of the text-orientation value.</param>
 41    /// <returns>A new <see cref="StyleTextOrientation" /> instance representing the parsed value.</returns>
 42    /// <exception cref="AryArgumentException">
 43    /// Thrown when the provided <paramref name="value" /> does not correspond to a valid <see cref="Kind" />.
 44    /// </exception>
 45    public static StyleTextOrientation Parse(string? value)
 1046        => value.TryParseEnum<Kind>(result: out var kind)
 1047            ? new StyleTextOrientation(kind: kind)
 1048            : throw new AryArgumentException(message: $"Invalid style: {value}", argName: nameof(value));
 49
 50    /// <summary>Attempts to parse a string into a <see cref="StyleTextOrientation" /> instance.</summary>
 51    /// <param name="value">The string representation of the text-orientation value to parse.</param>
 52    /// <param name="result">
 53    /// When this method returns, contains the parsed <see cref="StyleTextOrientation" /> instance or <see langword="nul
 54    /// if parsing failed.
 55    /// </param>
 56    /// <returns><see langword="true" /> if parsing succeeded; otherwise, <see langword="false" />.</returns>
 57    public static bool TryParse(string? value, out StyleTextOrientation? result)
 58    {
 59        try
 60        {
 361            result = Parse(value: value);
 62
 163            return true;
 64        }
 265        catch
 66        {
 267            result = null;
 68
 269            return false;
 70        }
 371    }
 72
 73    /// <summary>Implicitly converts a string into a <see cref="StyleTextOrientation" /> instance.</summary>
 74    /// <param name="value">The string representation of the text-orientation value.</param>
 75    /// <returns>A <see cref="StyleTextOrientation" /> instance representing the provided value.</returns>
 76    /// <exception cref="AryArgumentException">
 77    /// Thrown when the provided string cannot be parsed into a valid
 78    /// <see cref="Kind" />.
 79    /// </exception>
 280    public static implicit operator StyleTextOrientation(string? value) => Parse(value: value);
 81
 82    /// <summary>Implicitly converts a <see cref="StyleTextOrientation" /> instance to its string representation.</summa
 83    /// <param name="value">The <see cref="StyleTextOrientation" /> instance to convert.</param>
 84    /// <returns>
 85    /// The underlying CSS <c>text-orientation</c> string value, or an empty string if <paramref name="value" /> is
 86    /// <see langword="null" />.
 87    /// </returns>
 288    public static implicit operator string(StyleTextOrientation? value) => (value?.Value).OrDefaultIfEmpty();
 89}