< Summary

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

#LineLine coverage
 1namespace Allyaria.Theming.StyleTypes;
 2
 3/// <summary>
 4/// Represents a CSS <c>overscroll-behavior</c>, <c>overscroll-behavior-x</c>, or <c>overscroll-behavior-y</c> value wit
 5/// the Allyaria theming system. Provides a strongly typed wrapper for controlling browser scroll chaining and overscrol
 6/// behavior.
 7/// </summary>
 8public sealed record StyleOverscrollBehavior : StyleValueBase
 9{
 10    /// <summary>
 11    /// Initializes a new instance of the <see cref="StyleOverscrollBehavior" /> record using the specified <see cref="K
 12    /// value.
 13    /// </summary>
 14    /// <param name="kind">The overscroll behavior to represent.</param>
 15    public StyleOverscrollBehavior(Kind kind)
 2416        : base(value: kind.GetDescription()) { }
 17
 18    /// <summary>Defines the supported CSS <c>overscroll-behavior</c> property values.</summary>
 19    public enum Kind
 20    {
 21        /// <summary>
 22        /// Allows the default scroll chaining behavior. Scrolls will propagate to parent containers or cause browser ge
 23        /// (such as pull-to-refresh).
 24        /// </summary>
 25        [Description(description: "auto")]
 26        Auto,
 27
 28        /// <summary>
 29        /// Prevents scroll chaining to parent containers, but allows default browser gestures (e.g., pull-to-refresh).
 30        /// </summary>
 31        [Description(description: "contain")]
 32        Contain,
 33
 34        /// <summary>Completely disables scroll chaining and default browser gestures caused by reaching scroll limits.<
 35        [Description(description: "none")]
 36        None
 37    }
 38
 39    /// <summary>
 40    /// Parses a string representation of a CSS <c>overscroll-behavior</c> value into a <see cref="StyleOverscrollBehavi
 41    /// instance.
 42    /// </summary>
 43    /// <param name="value">The string representation of the overscroll behavior value.</param>
 44    /// <returns>A new <see cref="StyleOverscrollBehavior" /> instance representing the parsed value.</returns>
 45    /// <exception cref="AryArgumentException">
 46    /// Thrown when the provided <paramref name="value" /> does not correspond to a valid <see cref="Kind" />.
 47    /// </exception>
 48    public static StyleOverscrollBehavior Parse(string? value)
 1049        => value.TryParseEnum<Kind>(result: out var kind)
 1050            ? new StyleOverscrollBehavior(kind: kind)
 1051            : throw new AryArgumentException(message: $"Invalid style: {value}", argName: nameof(value));
 52
 53    /// <summary>Attempts to parse a string into a <see cref="StyleOverscrollBehavior" /> instance.</summary>
 54    /// <param name="value">The string representation of the overscroll behavior value to parse.</param>
 55    /// <param name="result">
 56    /// When this method returns, contains the parsed <see cref="StyleOverscrollBehavior" /> instance or
 57    /// <see langword="null" /> if parsing failed.
 58    /// </param>
 59    /// <returns><see langword="true" /> if parsing succeeded; otherwise, <see langword="false" />.</returns>
 60    public static bool TryParse(string? value, out StyleOverscrollBehavior? result)
 61    {
 62        try
 63        {
 364            result = Parse(value: value);
 65
 166            return true;
 67        }
 268        catch
 69        {
 270            result = null;
 71
 272            return false;
 73        }
 374    }
 75
 76    /// <summary>Implicitly converts a string into a <see cref="StyleOverscrollBehavior" /> instance.</summary>
 77    /// <param name="value">The string representation of the overscroll behavior value.</param>
 78    /// <returns>A <see cref="StyleOverscrollBehavior" /> instance representing the provided value.</returns>
 79    /// <exception cref="AryArgumentException">
 80    /// Thrown when the provided string cannot be parsed into a valid
 81    /// <see cref="Kind" />.
 82    /// </exception>
 283    public static implicit operator StyleOverscrollBehavior(string? value) => Parse(value: value);
 84
 85    /// <summary>Implicitly converts a <see cref="StyleOverscrollBehavior" /> instance to its string representation.</su
 86    /// <param name="value">The <see cref="StyleOverscrollBehavior" /> instance to convert.</param>
 87    /// <returns>
 88    /// The underlying CSS <c>overscroll-behavior</c> string value, or an empty string if <paramref name="value" /> is
 89    /// <see langword="null" />.
 90    /// </returns>
 291    public static implicit operator string(StyleOverscrollBehavior? value) => (value?.Value).OrDefaultIfEmpty();
 92}