Skip to content

Commit 95f58ea

Browse files
committed
Improved the definitions and equipped them with documentation comments
1 parent 5eb4254 commit 95f58ea

File tree

1 file changed

+30
-13
lines changed

1 file changed

+30
-13
lines changed

src/IGLib.Core/Console/Validation/DefaultFormatProvider/DefaultFormatProvider.cs

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,40 @@
44
using System.Linq;
55
using System.Text;
66

7-
namespace IGLib
8-
{
7+
namespace IGLib;
98

10-
public class DefaultFormatProviderSelector
11-
{
129

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+
{
1712

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();
2318

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);
2441
}
2542

2643
}

0 commit comments

Comments
 (0)