| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="ResxAddressFakerProvider.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.Geography; |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Provides fake address datasets from localized RESX resources. |
| | | 16 | | /// </summary> |
| | | 17 | | public sealed class ResxAddressFakerProvider : ResxProviderBase, IAddressFakerProvider |
| | | 18 | | { |
| | | 19 | | /// <summary> |
| | | 20 | | /// Creates a new instance of the <see cref="ResxAddressFakerProvider"/> 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="ResxAddressFakerProvider"/>.</returns> |
| | 6 | 24 | | public static ResxAddressFakerProvider Create(CultureInfo culture) => new(culture); |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Initializes a new instance of the <see cref="ResxAddressFakerProvider"/> 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 ResxAddressFakerProvider(CultureInfo culture) |
| | 6 | 32 | | : base(culture, AddressResources.ResourceManager) |
| | | 33 | | { |
| | 3 | 34 | | StreetTypes = LoadDataset(nameof(AddressResources.StreetTypes)); |
| | 3 | 35 | | StreetSuffixes = LoadDataset(nameof(AddressResources.StreetSuffixes)); |
| | 3 | 36 | | StreetNames = LoadDataset(nameof(AddressResources.StreetNames)); |
| | 3 | 37 | | StreetFormats = LoadDataset(nameof(AddressResources.StreetFormats)); |
| | 3 | 38 | | Cities = LoadDataset(nameof(AddressResources.Cities)); |
| | 3 | 39 | | PostalCodeFormats = LoadDataset(nameof(AddressResources.PostalCodeFormats)); |
| | 3 | 40 | | } |
| | | 41 | | |
| | | 42 | | /// <inheritdoc /> |
| | | 43 | | public IReadOnlyList<string> StreetTypes { get; } |
| | | 44 | | |
| | | 45 | | /// <inheritdoc /> |
| | | 46 | | public IReadOnlyList<string> StreetNames { get; } |
| | | 47 | | |
| | | 48 | | /// <inheritdoc /> |
| | | 49 | | public IReadOnlyList<string> StreetFormats { get; } |
| | | 50 | | |
| | | 51 | | /// <inheritdoc /> |
| | | 52 | | public IReadOnlyList<string> StreetSuffixes { get; } |
| | | 53 | | |
| | | 54 | | /// <inheritdoc /> |
| | | 55 | | public IReadOnlyList<string> Cities { get; } |
| | | 56 | | |
| | | 57 | | /// <inheritdoc /> |
| | | 58 | | public IReadOnlyList<string> PostalCodeFormats { get; } |
| | | 59 | | } |
| | | 60 | | |