| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="ResxNameFakerProvider.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.Generic; |
| | | 9 | | using System.Globalization; |
| | | 10 | | using MyNet.Fakers.Localization; |
| | | 11 | | |
| | | 12 | | namespace MyNet.Fakers.Identity; |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Provides fake name datasets from localized RESX resources. |
| | | 16 | | /// </summary> |
| | | 17 | | public sealed class ResxNameFakerProvider : ResxProviderBase, INameFakerProvider |
| | | 18 | | { |
| | | 19 | | /// <summary> |
| | | 20 | | /// Creates a new instance of the <see cref="ResxNameFakerProvider"/> class for the specified culture. |
| | | 21 | | /// </summary> |
| | | 22 | | /// <param name="culture">The culture associated with the provider.</param> |
| | | 23 | | /// <returns>A new instance of <see cref="ResxNameFakerProvider"/>.</returns> |
| | 12 | 24 | | public static ResxNameFakerProvider Create(CultureInfo culture) => new(culture); |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Initializes a new instance of the <see cref="ResxNameFakerProvider"/> class with the specified culture. |
| | | 28 | | /// </summary> |
| | | 29 | | /// <param name="culture">The culture associated with the provider.</param> |
| | | 30 | | /// <exception cref="ArgumentNullException">Thrown when the <paramref name="culture"/> is null.</exception> |
| | | 31 | | private ResxNameFakerProvider(CultureInfo culture) |
| | 12 | 32 | | : base(culture, NamesResources.ResourceManager) |
| | | 33 | | { |
| | 9 | 34 | | MaleFirstNames = LoadDataset(nameof(NamesResources.MaleFirstNames)); |
| | 9 | 35 | | FemaleFirstNames = LoadDataset(nameof(NamesResources.FemaleFirstNames)); |
| | 9 | 36 | | LastNames = LoadDataset(nameof(NamesResources.LastNames)); |
| | 9 | 37 | | Prefixes = LoadDataset(nameof(NamesResources.Prefixes)); |
| | 9 | 38 | | Suffixes = LoadDataset(nameof(NamesResources.Suffixes)); |
| | 9 | 39 | | } |
| | | 40 | | |
| | | 41 | | /// <inheritdoc /> |
| | | 42 | | public IReadOnlyList<string> MaleFirstNames { get; } |
| | | 43 | | |
| | | 44 | | /// <inheritdoc /> |
| | | 45 | | public IReadOnlyList<string> FemaleFirstNames { get; } |
| | | 46 | | |
| | | 47 | | /// <inheritdoc /> |
| | | 48 | | public IReadOnlyList<string> LastNames { get; } |
| | | 49 | | |
| | | 50 | | /// <inheritdoc /> |
| | | 51 | | public IReadOnlyList<string> Prefixes { get; } |
| | | 52 | | |
| | | 53 | | /// <inheritdoc /> |
| | | 54 | | public IReadOnlyList<string> Suffixes { get; } |
| | | 55 | | } |
| | | 56 | | |