| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="DisplayTextStrategyRegistry.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System; |
| | | 8 | | using System.Collections.Frozen; |
| | | 9 | | using System.Collections.Generic; |
| | | 10 | | using System.Diagnostics.CodeAnalysis; |
| | | 11 | | |
| | | 12 | | namespace MyNet.Humanizer.Display.Registration; |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Current implementation of <see cref="IDisplayTextStrategyRegistry"/> that stores strategies in a frozen dictionary f |
| | | 16 | | /// </summary> |
| | | 17 | | /// <param name="strategies">The strategies to be registered.</param> |
| | | 18 | | public sealed class DisplayTextStrategyRegistry(IReadOnlyDictionary<Type, IDisplayTextStrategy> strategies) : IDisplayTe |
| | | 19 | | { |
| | 31 | 20 | | private readonly FrozenDictionary<Type, IDisplayTextStrategy> _strategies = strategies.ToFrozenDictionary(); |
| | | 21 | | |
| | | 22 | | /// <inheritdoc /> |
| | 30 | 23 | | public IReadOnlyDictionary<Type, IDisplayTextStrategy> Strategies => _strategies; |
| | | 24 | | |
| | | 25 | | /// <inheritdoc /> |
| | 35 | 26 | | public bool TryGetStrategy(Type targetType, [NotNullWhen(true)] out IDisplayTextStrategy? strategy) => _strategies.T |
| | | 27 | | } |
| | | 28 | | |