-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathStringConvertManager.cs
More file actions
65 lines (53 loc) · 1.68 KB
/
Copy pathStringConvertManager.cs
File metadata and controls
65 lines (53 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
namespace IntXLib
{
/// <summary>
/// Used to retrieve needed ToString converter.
/// </summary>
static internal class StringConvertManager
{
#region Fields
/// <summary>
/// Classic converter instance.
/// </summary>
static readonly public IStringConverter ClassicStringConverter;
/// <summary>
/// Fast converter instance.
/// </summary>
static readonly public IStringConverter FastStringConverter;
#endregion Fields
#region Constructors
// .cctor
static StringConvertManager()
{
// Create new pow2 converter instance
IStringConverter pow2StringConverter = new Pow2StringConverter();
// Create new classic converter instance
IStringConverter classicStringConverter = new ClassicStringConverter(pow2StringConverter);
// Fill publicity visible converter fields
ClassicStringConverter = classicStringConverter;
FastStringConverter = new FastStringConverter(pow2StringConverter, classicStringConverter);
}
#endregion Constructors
#region Methods
/// <summary>
/// Returns ToString converter instance for given ToString mode.
/// </summary>
/// <param name="mode">ToString mode.</param>
/// <returns>Converter instance.</returns>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="mode" /> is out of range.</exception>
static public IStringConverter GetStringConverter(ToStringMode mode)
{
switch (mode)
{
case ToStringMode.Fast:
return FastStringConverter;
case ToStringMode.Classic:
return ClassicStringConverter;
default:
throw new ArgumentOutOfRangeException("mode");
}
}
#endregion Methods
}
}