/
Services.cs
80 lines (69 loc) · 2.04 KB
/
Services.cs
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using FluentAssertions.Execution;
namespace FluentAssertions.Common
{
/// <summary>
/// Maintains the framework-specific services.
/// </summary>
public static class Services
{
private static readonly object lockable = new object();
private static Configuration configuration;
private static Action<string> throwException;
private static IReflector reflector;
private static IConfigurationStore configurationStore;
static Services()
{
ResetToDefaults();
}
public static IConfigurationStore ConfigurationStore
{
get => configurationStore;
set => configurationStore = value;
}
public static Configuration Configuration
{
get
{
lock (lockable)
{
if (configuration == null)
{
configuration = new Configuration(ConfigurationStore);
}
return configuration;
}
}
}
public static Action<string> ThrowException
{
get
{
return throwException;
}
set
{
throwException = value;
}
}
public static IReflector Reflector
{
get { return reflector; }
set { reflector = value; }
}
public static void ResetToDefaults()
{
#if NET45 || NET47 || NETSTANDARD2_0 || NETCOREAPP2_0
reflector = new FullFrameworkReflector();
configurationStore = new AppSettingsConfigurationStore();
#elif NETSTANDARD1_6
reflector = new NetStandardReflector();
configurationStore = new NullConfigurationStore();
#else
reflector = new NullReflector();
configurationStore = new NullConfigurationStore();
#endif
throwException = TestFrameworkProvider.Throw;
}
}
}