Repository navigation
Expand file tree
/
Copy pathAppSettings.cs
More file actions
50 lines (45 loc) · 1.9 KB
/
Copy pathAppSettings.cs
File metadata and controls
50 lines (45 loc) · 1.9 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
//------------------------------------------------------------------------------
// <copyright file="AppSettings.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
// AppSettings.cs
//
using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.ComponentModel.DataAnnotations.Util;
namespace System.ComponentModel.DataAnnotations {
internal static class AppSettings {
private static volatile bool _settingsInitialized = false;
private static object _appSettingsLock = new object();
private static void EnsureSettingsLoaded() {
if (!_settingsInitialized) {
lock (_appSettingsLock) {
if (!_settingsInitialized) {
NameValueCollection settings = null;
try {
settings = ConfigurationManager.AppSettings;
}
catch (ConfigurationErrorsException) { }
finally {
if (settings == null || !Boolean.TryParse(settings["dataAnnotations:dataTypeAttribute:disableRegEx"], out _disableRegEx)) {
//VSO480141 Disable RegEx by default for DataAnotationAttributes in .NET 4.7.2
_disableRegEx = BinaryCompatibility.Current.TargetsAtLeastFramework472;
}
_settingsInitialized = true;
}
}
}
}
}
private static bool _disableRegEx;
internal static bool DisableRegEx {
get {
EnsureSettingsLoaded();
return _disableRegEx;
}
}
}
}