< Summary

Information
Class: MyNet.Globalization.GlobalizationOptions
Assembly: MyNet.Globalization
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Globalization/GlobalizationOptions.cs
Tag: 323_28699572109
Line coverage
85%
Covered lines: 6
Uncovered lines: 1
Coverable lines: 7
Total lines: 62
Line coverage: 85.7%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%210%
set_DefaultCulture(...)100%11100%
set_DefaultTimeZone(...)100%11100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Globalization/GlobalizationOptions.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="GlobalizationOptions.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using System.Globalization;
 9using MyNet.Globalization.Localization.Policies;
 10
 11namespace MyNet.Globalization;
 12
 13/// <summary>
 14/// Configuration options for globalization services including default culture and time zone.
 15/// </summary>
 16public sealed class GlobalizationOptions
 17{
 18    /// <summary>
 19    /// Gets the default globalization options instance with default culture and time zone.
 20    /// </summary>
 021    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        {
 332            ArgumentNullException.ThrowIfNull(value);
 333            field = value;
 334        }
 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        {
 348            ArgumentNullException.ThrowIfNull(value);
 349            field = value;
 350        }
 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