< Summary

Information
Class: MyNet.Humanizer.Display.DisplayTextService
Assembly: MyNet.Humanizer
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Humanizer/Display/DisplayTextService.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 28
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
GetDisplayText(...)100%44100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Humanizer/Display/DisplayTextService.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="DisplayTextService.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System.Globalization;
 8using MyNet.Globalization.Culture;
 9
 10namespace MyNet.Humanizer.Display;
 11
 12/// <summary>
 13/// Current implementation of <see cref="IDisplayTextService"/> that retrieves display texts using registered display te
 14/// </summary>
 15/// <param name="resolver">The resolver used to obtain the appropriate display text strategy for a given type.</param>
 16/// <param name="cultureContext">The culture context used to determine the current culture.</param>
 17public class DisplayTextService(IDisplayTextStrategyResolver resolver, ICultureContext cultureContext) : IDisplayTextSer
 18{
 19    /// <inheritdoc/>
 20    public string GetDisplayText<T>(T value, DisplayTextOptions options, CultureInfo? culture = null)
 21        where T : notnull
 22    {
 11623        var cultureToUse = culture ?? cultureContext.CurrentCulture;
 24
 11625        return typeof(T) == value.GetType() ? resolver.GetRequired<T>().GetDisplayText(value, options, cultureToUse) : r
 26    }
 27}
 28