| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="ResxProviderBase.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.Immutable; |
| | | 9 | | using System.Globalization; |
| | | 10 | | using System.Resources; |
| | | 11 | | using MyNet.Fakers.Localization; |
| | | 12 | | using MyNet.Globalization.Localization.Providers; |
| | | 13 | | |
| | | 14 | | namespace MyNet.Fakers; |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Base class for RESX-based pattern providers. This class provides common functionality for loading localized datasets |
| | | 18 | | /// </summary> |
| | | 19 | | /// <param name="culture">The culture associated with this provider, used for loading localized datasets from RESX resou |
| | | 20 | | /// <param name="resourceManager">The resource manager used to load localized datasets from RESX resources.</param> |
| | | 21 | | public abstract class ResxProviderBase(CultureInfo culture, ResourceManager resourceManager) : ICultureScoped |
| | | 22 | | { |
| | | 23 | | /// <summary> |
| | | 24 | | /// Gets the culture associated with this provider, used for loading localized datasets from RESX resources. |
| | | 25 | | /// </summary> |
| | 30 | 26 | | public CultureInfo Culture { get; } = culture ?? throw new ArgumentNullException(nameof(culture)); |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Gets the resource manager used to load localized datasets from RESX resources. This is typically initialized in |
| | | 30 | | /// </summary> |
| | 18 | 31 | | protected ResourceManager ResourceManager { get; } = resourceManager ?? throw new ArgumentNullException(nameof(resou |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Loads a localized string list from a RESX resource using the provided key. This method utilizes the <see cref="R |
| | | 35 | | /// </summary> |
| | | 36 | | /// <param name="key">The key of the resource to load.</param> |
| | | 37 | | /// <returns>A read-only list of localized strings.</returns> |
| | 78 | 38 | | protected ImmutableArray<string> LoadDataset(string key) => ResourceDatasetLoader.LoadList(ResourceManager, key, Cul |
| | | 39 | | } |
| | | 40 | | |