< Summary

Information
Class: Allyaria.Theming.Contracts.ThemeApplierBase
Assembly: Allyaria.Theming
File(s): /home/runner/work/allyaria/allyaria/src/Allyaria.Theming/Contracts/ThemeApplierBase.cs
Line coverage
100%
Covered lines: 23
Uncovered lines: 0
Coverable lines: 23
Total lines: 74
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_ComponentType()100%11100%
get_Count()100%11100%
get_IsHighContrast()100%11100%
get_ThemeMapper()100%11100%
get_Item(...)100%11100%
Add(...)100%11100%
AddRange(...)100%11100%
CreateUpdater(...)100%11100%
GetEnumerator()100%11100%
System.Collections.IEnumerable.GetEnumerator()100%11100%

File(s)

/home/runner/work/allyaria/allyaria/src/Allyaria.Theming/Contracts/ThemeApplierBase.cs

#LineLine coverage
 1namespace Allyaria.Theming.Contracts;
 2
 3/// <summary>
 4/// Provides a base implementation for applying theme updates across components, managing a collection of
 5/// <see cref="ThemeUpdater" /> instances that describe style changes for various theme states and components.
 6/// </summary>
 7internal abstract class ThemeApplierBase : IReadOnlyList<ThemeUpdater>
 8{
 9    /// <summary>Internal backing list for theme updaters.</summary>
 45410    private readonly List<ThemeUpdater> _internalList = new();
 11
 12    /// <summary>Initializes a new instance of the <see cref="ThemeApplierBase" /> class.</summary>
 13    /// <param name="themeMapper">The <see cref="ThemeMapper" /> instance used to resolve style mappings.</param>
 14    /// <param name="isHighContrast">A value indicating whether the theme is high-contrast.</param>
 15    /// <param name="componentType">The <see cref="ComponentType" /> to which the theme applies.</param>
 45416    protected ThemeApplierBase(ThemeMapper themeMapper, bool isHighContrast, ComponentType componentType)
 17    {
 45418        ThemeMapper = themeMapper;
 45419        IsHighContrast = isHighContrast;
 45420        ComponentType = componentType;
 45421    }
 22
 23    /// <summary>Gets the component type this applier targets.</summary>
 129224    protected ComponentType ComponentType { get; }
 25
 26    /// <summary>Gets the number of <see cref="ThemeUpdater" /> items contained within this instance.</summary>
 1527    public int Count => _internalList.Count;
 28
 29    /// <summary>Gets a value indicating whether the current theme is high-contrast.</summary>
 129230    protected bool IsHighContrast { get; }
 31
 32    /// <summary>Gets the <see cref="ThemeMapper" /> responsible for mapping style data to theme properties.</summary>
 37333    protected ThemeMapper ThemeMapper { get; }
 34
 35    /// <summary>Gets the <see cref="ThemeUpdater" /> at the specified index.</summary>
 36    /// <param name="index">The zero-based index of the element to retrieve.</param>
 37    /// <returns>The <see cref="ThemeUpdater" /> at the specified index.</returns>
 438    public ThemeUpdater this[int index] => _internalList[index: index];
 39
 40    /// <summary>Adds a single <see cref="ThemeUpdater" /> to the internal collection.</summary>
 41    /// <param name="item">The <see cref="ThemeUpdater" /> to add.</param>
 93742    protected void Add(ThemeUpdater item) => _internalList.Add(item: item);
 43
 44    /// <summary>Adds a range of <see cref="ThemeUpdater" /> items to the internal collection.</summary>
 45    /// <param name="collection">A read-only list of <see cref="ThemeUpdater" /> instances to append.</param>
 41146    protected void AddRange(IReadOnlyList<ThemeUpdater> collection) => _internalList.AddRange(collection: collection);
 47
 48    /// <summary>
 49    /// Creates a new <see cref="ThemeUpdater" /> for the specified style type and value, automatically setting the rele
 50    /// <see cref="ThemeNavigator" /> parameters.
 51    /// </summary>
 52    /// <param name="styleType">The style type associated with this updater.</param>
 53    /// <param name="value">The value to apply for the style type.</param>
 54    /// <returns>A constructed <see cref="ThemeUpdater" /> with navigation and value set.</returns>
 55    protected ThemeUpdater CreateUpdater(StyleType styleType, IStyleValue value)
 91956        => new(
 91957            Navigator: ThemeNavigator.Initialize
 91958                .SetComponentTypes(items: ComponentType)
 91959                .SetContrastThemeTypes(isHighContrast: IsHighContrast)
 91960                .SetAllComponentStates()
 91961                .SetStyleTypes(styleType),
 91962            Value: value
 91963        );
 64
 65    /// <summary>Returns an enumerator that iterates through the contained <see cref="ThemeUpdater" /> collection.</summ
 66    /// <returns>An enumerator for the collection.</returns>
 47167    public IEnumerator<ThemeUpdater> GetEnumerator() => _internalList.GetEnumerator();
 68
 69    /// <summary>
 70    /// Returns a non-generic enumerator that iterates through the contained <see cref="ThemeUpdater" /> collection.
 71    /// </summary>
 72    /// <returns>A non-generic enumerator for the collection.</returns>
 173    IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)_internalList).GetEnumerator();
 74}