| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="CultureExtensions.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System.Globalization; |
| | | 8 | | |
| | | 9 | | #pragma warning disable IDE0130 // Namespace does not match folder structure |
| | | 10 | | namespace MyNet.Primitives; |
| | | 11 | | #pragma warning restore IDE0130 // Namespace does not match folder structure |
| | | 12 | | |
| | | 13 | | public static class CultureExtensions |
| | | 14 | | { |
| | | 15 | | extension(CultureInfo? culture) |
| | | 16 | | { |
| | | 17 | | /// <summary> |
| | | 18 | | /// Determines whether the provided culture is the current culture. If <paramref name="culture"/> is null, it is |
| | | 19 | | /// </summary> |
| | 3 | 20 | | public bool IsCurrent() => culture?.Equals(CultureInfo.CurrentCulture) != false; |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// Returns the current culture if <paramref name="culture"/> is null, otherwise returns <paramref name="culture |
| | | 24 | | /// </summary> |
| | | 25 | | /// <returns>The current culture if <paramref name="culture"/> is null, otherwise the provided culture.</returns |
| | 585 | 26 | | public CultureInfo OrCurrent() => culture.Or(CultureInfo.CurrentCulture); |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Returns the invariant culture if <paramref name="culture"/> is null, otherwise returns <paramref name="cultu |
| | | 30 | | /// </summary> |
| | | 31 | | /// <returns>The invariant culture if <paramref name="culture"/> is null, otherwise the provided culture.</retur |
| | 3 | 32 | | public CultureInfo OrInvariant() => culture.Or(CultureInfo.InvariantCulture); |
| | | 33 | | } |
| | | 34 | | } |
| | | 35 | | |