|
1 | 1 | // // Copyright (c) Microsoft Corporation. |
2 | 2 | // // Licensed under the MIT License. |
3 | 3 |
|
4 | | -using EventLogExpert.Eventing.Helpers; |
5 | 4 | using System.Reflection; |
6 | 5 | using System.Runtime.Serialization; |
7 | | -using System.Text; |
8 | 6 |
|
9 | 7 | namespace EventLogExpert; |
10 | 8 |
|
11 | 9 | internal static class ExtensionMethods |
12 | 10 | { |
13 | | - internal static void AndForget(this Task task, ITraceLogger? logger = null) |
| 11 | + extension(DateTime time) |
14 | 12 | { |
15 | | - if (!task.IsCompleted || task.IsFaulted) { _ = ForgetAwaited(task, logger); } |
| 13 | + internal DateTime ConvertTimeZone(TimeZoneInfo? destinationTime) => |
| 14 | + destinationTime is null ? time : TimeZoneInfo.ConvertTimeFromUtc(time, destinationTime); |
16 | 15 |
|
17 | | - static async Task ForgetAwaited(Task task, ITraceLogger? logger = null) |
18 | | - { |
19 | | - try |
20 | | - { |
21 | | - await task.ConfigureAwait(false); |
22 | | - } |
23 | | - catch (Exception ex) |
24 | | - { |
25 | | - logger?.Trace(ex.Message); |
26 | | - } |
27 | | - } |
| 16 | + internal DateTime ConvertTimeZoneToUtc(TimeZoneInfo? destinationTime) => |
| 17 | + destinationTime is null ? time : TimeZoneInfo.ConvertTimeToUtc(time, destinationTime); |
28 | 18 | } |
29 | 19 |
|
30 | | - internal static DateTime ConvertTimeZone(this DateTime time, TimeZoneInfo? destinationTime) => |
31 | | - destinationTime is null ? time : TimeZoneInfo.ConvertTimeFromUtc(time, destinationTime); |
32 | | - |
33 | | - internal static DateTime ConvertTimeZoneToUtc(this DateTime time, TimeZoneInfo? destinationTime) => |
34 | | - destinationTime is null ? time : TimeZoneInfo.ConvertTimeToUtc(time, destinationTime); |
35 | | - |
36 | 20 | internal static string ToFullString(this Enum value) |
37 | 21 | { |
38 | 22 | var memberAttribute = value.GetType().GetField(value.ToString())? |
|
0 commit comments