| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="GlobalizationOptions.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System; |
| | | 8 | | using System.Globalization; |
| | | 9 | | using MyNet.Globalization.Localization.Policies; |
| | | 10 | | |
| | | 11 | | namespace MyNet.Globalization; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Configuration options for globalization services including default culture and time zone. |
| | | 15 | | /// </summary> |
| | | 16 | | public sealed class GlobalizationOptions |
| | | 17 | | { |
| | | 18 | | /// <summary> |
| | | 19 | | /// Gets the default globalization options instance with default culture and time zone. |
| | | 20 | | /// </summary> |
| | 0 | 21 | | public static GlobalizationOptions Default { get; } = new(); |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Gets the default culture used when no culture is explicitly set. |
| | | 25 | | /// </summary> |
| | | 26 | | /// <exception cref="ArgumentNullException">Thrown when setting to null.</exception> |
| | | 27 | | public CultureInfo DefaultCulture |
| | | 28 | | { |
| | | 29 | | get; |
| | | 30 | | init |
| | | 31 | | { |
| | 3 | 32 | | ArgumentNullException.ThrowIfNull(value); |
| | 3 | 33 | | field = value; |
| | 3 | 34 | | } |
| | | 35 | | } |
| | | 36 | | |
| | | 37 | | = CultureInfo.CurrentCulture; |
| | | 38 | | |
| | | 39 | | /// <summary> |
| | | 40 | | /// Gets the default time zone used when no time zone is explicitly set. |
| | | 41 | | /// </summary> |
| | | 42 | | /// <exception cref="ArgumentNullException">Thrown when setting to null.</exception> |
| | | 43 | | public TimeZoneInfo DefaultTimeZone |
| | | 44 | | { |
| | | 45 | | get; |
| | | 46 | | init |
| | | 47 | | { |
| | 3 | 48 | | ArgumentNullException.ThrowIfNull(value); |
| | 3 | 49 | | field = value; |
| | 3 | 50 | | } |
| | | 51 | | } |
| | | 52 | | |
| | | 53 | | = TimeZoneInfo.Local; |
| | | 54 | | |
| | | 55 | | /// <summary> |
| | | 56 | | /// Gets the culture fallback policy used by translators and provider resolvers. |
| | | 57 | | /// Defaults to <see cref="CultureFallbackPolicies.ParentCulture"/> (walks up the culture hierarchy). |
| | | 58 | | /// Use <see cref="CultureFallbackPolicies.None"/> to disable fallback. |
| | | 59 | | /// </summary> |
| | | 60 | | public ICultureFallbackPolicy CultureFallbackPolicy { get; init; } = CultureFallbackPolicies.ParentCulture; |
| | | 61 | | } |
| | | 62 | | |