|
4 | 4 | using System.Linq; |
5 | 5 | using System.Text; |
6 | 6 |
|
7 | | -namespace IGLib |
8 | | -{ |
| 7 | +namespace IGLib; |
9 | 8 |
|
10 | | - public class DefaultFormatProviderSelector |
11 | | - { |
12 | 9 |
|
13 | | - /// <summary>Returns the global <see cref="IDefaultFormatProviderSelector"/> that is used to provide |
14 | | - /// the <see cref="IFormatProvider"/> when one is not specified, and also the the |
15 | | - /// <see cref="IDefaultFormatProviderSelector"/> is not specified.</summary> |
16 | | - public static IDefaultFormatProviderSelector Global { get; private set; } = |
| 10 | +public class DefaultFormatProviderSelector |
| 11 | +{ |
17 | 12 |
|
18 | | - public static IFormatProvider GetFormatProvider(IFormatProvider? specifiedProvider, |
19 | | - IDefaultFormatProviderSelector? selector) |
20 | | - { |
21 | | - return (specifiedProvider ?? (selector?? Global).DefaultFormatProvider); |
22 | | - } |
| 13 | + /// <summary>Returns the global <see cref="IDefaultFormatProviderSelector"/> that is used to provide |
| 14 | + /// the <see cref="IFormatProvider"/> when one is not specified, and also the the |
| 15 | + /// <see cref="IDefaultFormatProviderSelector"/> is not specified.</summary> |
| 16 | + public static IDefaultFormatProviderSelector Global { get; private set; } |
| 17 | + = new DefaultFormatProviderSelectorInvariantCulture(); |
23 | 18 |
|
| 19 | + /// <summary>Returns the appropriate <see cref="IFormatProvider"/> according to the specified (suggested) |
| 20 | + /// <paramref name="specifiedFormatProvider"/> (that can be null) and the specified <paramref name="defaultSelector"/>, |
| 21 | + /// which provides the default <see cref="IFormatProvider"/> when the <paramref name="specifiedFormatProvider"/> |
| 22 | + /// is null If both parameters are null then the default <see cref="IFormatProvider"/> is provided by the |
| 23 | + /// <see cref="DefaultFormatProviderSelector.Global"/> property.</summary> |
| 24 | + /// <param name="specifiedFormatProvider">The specified <see cref="IFormatProvider"/>. If not null then this |
| 25 | + /// object is returned immediately, otherwise the <paramref name="defaultSelector"/> parameter is used to |
| 26 | + /// provide the object that is returned.</param> |
| 27 | + /// <param name="defaultSelector">Provides the default <see cref="IFormatProvider"/> (via the |
| 28 | + /// <see cref="IDefaultFormatProviderSelector.DefaultFormatProvider"/> property) in case that the <paramref name="specifiedFormatProvider"/> |
| 29 | + /// is null. In that case, if this parameter is also null, the <see cref="DefaultFormatProviderSelector.Global"/> provides the |
| 30 | + /// default object to be returned.</param> |
| 31 | + /// <returns>The <see cref="IFormatProvider"/> returned according to method parameters: |
| 32 | + /// <para>* If <paramref name="specifiedFormatProvider"/> is not null, this object is returned.</para> |
| 33 | + /// <para>* Otherwise, if <paramref name="defaultSelector"/> is not null then the object obtained by its |
| 34 | + /// <see cref="IDefaultFormatProviderSelector.DefaultFormatProvider"/> property is returned.</para> |
| 35 | + /// <para>Otherwise, the format provider obtained by the <see cref="DefaultFormatProviderSelector.Global"/>'s |
| 36 | + /// <see cref="IDefaultFormatProviderSelector.DefaultFormatProvider"/> property is returned.</para></returns> |
| 37 | + public static IFormatProvider GetFormatProvider(IFormatProvider? specifiedFormatProvider, |
| 38 | + IDefaultFormatProviderSelector? defaultSelector) |
| 39 | + { |
| 40 | + return (specifiedFormatProvider ?? (defaultSelector ?? Global).DefaultFormatProvider); |
24 | 41 | } |
25 | 42 |
|
26 | 43 | } |
0 commit comments