Skip to content

Commit c9744a3

Browse files
committed
Added FormatProviderDefaults.cs
1 parent 5ecf13a commit c9744a3

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+

2+
using System;
3+
using System.Globalization;
4+
5+
namespace IGLib.Alt;
6+
7+
public static class FormatProviderDefaults
8+
{
9+
public static IFormatProvider Global { get; private set; } = CultureInfo.InvariantCulture;
10+
11+
public static void SetGlobal(IFormatProvider formatProvider)
12+
{
13+
if (formatProvider == null)
14+
throw new ArgumentNullException(nameof(formatProvider));
15+
16+
Global = formatProvider;
17+
}
18+
19+
public static IFormatProvider Resolve(IFormatProvider? specifiedFormatProvider)
20+
=> specifiedFormatProvider ?? Global;
21+
}
22+

0 commit comments

Comments
 (0)