| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="GlobalizationEvents.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System; |
| | | 8 | | using MyNet.Globalization.Culture; |
| | | 9 | | using MyNet.Globalization.DateTime; |
| | | 10 | | |
| | | 11 | | namespace MyNet.Globalization.Events; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Implements the <see cref="IGlobalizationEvents"/> interface and provides events for culture and time zone changes. |
| | | 15 | | /// </summary> |
| | | 16 | | public 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 | | { |
| | 0 | 28 | | _cultureService = cultureService; |
| | 0 | 29 | | _timeZoneService = timeZoneService; |
| | | 30 | | |
| | | 31 | | _cultureService.CultureChanged += (s, e) => CultureChanged?.Invoke(s, e); |
| | | 32 | | _timeZoneService.TimeZoneChanged += (s, e) => TimeZoneChanged?.Invoke(s, e); |
| | 0 | 33 | | } |
| | | 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 | | |