| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="TypedDisplayTextStrategyAdapter.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System.Globalization; |
| | | 8 | | |
| | | 9 | | namespace MyNet.Humanizer.Display; |
| | | 10 | | |
| | | 11 | | /// <summary> |
| | | 12 | | /// Adapter that allows an untyped <see cref="IDisplayTextStrategy"/> to be used as a typed <see cref="IDisplayTextStrat |
| | | 13 | | /// </summary> |
| | | 14 | | /// <param name="inner">The inner untyped display text strategy.</param> |
| | | 15 | | /// <typeparam name="T">The target type for the typed display text strategy.</typeparam> |
| | | 16 | | public sealed class TypedDisplayTextStrategyAdapter<T>(IDisplayTextStrategy inner) : IDisplayTextStrategy<T> |
| | | 17 | | where T : notnull |
| | | 18 | | { |
| | | 19 | | /// <summary> |
| | | 20 | | /// Gets the display text for the given value using the inner untyped strategy. The value is passed as an object to |
| | | 21 | | /// </summary> |
| | | 22 | | /// <param name="value">The value for which to get the display text.</param> |
| | | 23 | | /// <param name="options">The display text options.</param> |
| | | 24 | | /// <param name="culture">The culture to use for formatting.</param> |
| | | 25 | | /// <returns>The display text for the given value.</returns> |
| | 15 | 26 | | public string GetDisplayText(T value, DisplayTextOptions options, CultureInfo culture) => inner.GetDisplayText(value |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Gets the display text for the given value using the inner untyped strategy. This method is part of the IDisplayT |
| | | 30 | | /// </summary> |
| | | 31 | | /// <param name="value">The value for which to get the display text.</param> |
| | | 32 | | /// <param name="options">The display text options.</param> |
| | | 33 | | /// <param name="culture">The culture to use for formatting.</param> |
| | | 34 | | /// <returns>The display text for the given value.</returns> |
| | 0 | 35 | | public string GetDisplayText(object value, DisplayTextOptions options, CultureInfo culture) => inner.GetDisplayText( |
| | | 36 | | } |
| | | 37 | | |