< Summary

Information
Class: MyNet.Globalization.Events.GlobalizationEvents
Assembly: MyNet.Globalization
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Globalization/Events/GlobalizationEvents.cs
Tag: 323_28699572109
Line coverage
0%
Covered lines: 0
Uncovered lines: 3
Coverable lines: 3
Total lines: 45
Line coverage: 0%
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
.ctor(...)100%210%

File(s)

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

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="GlobalizationEvents.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using MyNet.Globalization.Culture;
 9using MyNet.Globalization.DateTime;
 10
 11namespace MyNet.Globalization.Events;
 12
 13/// <summary>
 14/// Implements the <see cref="IGlobalizationEvents"/> interface and provides events for culture and time zone changes.
 15/// </summary>
 16public sealed class GlobalizationEvents : IGlobalizationEvents
 17{
 18    private readonly ICultureService _cultureService;
 19    private readonly ITimeZoneService _timeZoneService;
 20
 21    /// <summary>
 22    /// Initializes a new instance of the <see cref="GlobalizationEvents"/> class with the specified culture and time zo
 23    /// </summary>
 24    /// <param name="cultureService">The culture service to use for culture-related events.</param>
 25    /// <param name="timeZoneService">The time zone service to use for time zone-related events.</param>
 26    public GlobalizationEvents(ICultureService cultureService, ITimeZoneService timeZoneService)
 27    {
 028        _cultureService = cultureService;
 029        _timeZoneService = timeZoneService;
 30
 31        _cultureService.CultureChanged += (s, e) => CultureChanged?.Invoke(s, e);
 32        _timeZoneService.TimeZoneChanged += (s, e) => TimeZoneChanged?.Invoke(s, e);
 033    }
 34
 35    /// <summary>
 36    /// Occurs when the culture changes. Subscribers can handle this event to respond to culture changes in the applicat
 37    /// </summary>
 38    public event EventHandler<CultureChangedEventArgs>? CultureChanged;
 39
 40    /// <summary>
 41    /// Occurs when the time zone changes. Subscribers can handle this event to respond to time zone changes in the appl
 42    /// </summary>
 43    public event EventHandler<TimeZoneChangedEventArgs>? TimeZoneChanged;
 44}
 45