Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Data.Entity / Util / AppSettings.cs
1 //---------------------------------------------------------------------
2 // <copyright file="ObjectContext.cs" company="Microsoft">
3 //      Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //
6 // @owner       daobando
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
9
10 using System.Collections.Specialized;
11 using System.Configuration;
12
13 namespace System.Data.Entity.Util
14 {
15     internal static class AppSettings
16     {
17         private static volatile bool _settingsInitialized = false;
18         private static object _appSettingsLock = new object();
19         private static void EnsureSettingsLoaded()
20         {
21             if (!_settingsInitialized)
22             {
23                 lock (_appSettingsLock)
24                 {
25                     if (!_settingsInitialized)
26                     {
27                         NameValueCollection settings = null;
28                         try
29                         {
30                             settings = ConfigurationManager.AppSettings;
31                         }
32                         finally
33                         {
34                             if (settings == null || !Boolean.TryParse(settings["EntityFramework_SimplifyLimitOperations"], out _SimplifyLimitOperations))
35                             {
36                                 _SimplifyLimitOperations = false;
37                             }
38
39                             if (settings == null || !Boolean.TryParse(settings["EntityFramework_SimplifyUserSpecifiedViews"], out _SimplifyUserSpecifiedViews))
40                             {
41                                 _SimplifyUserSpecifiedViews = true;
42                             }
43
44                             _settingsInitialized = true;
45                         }
46                     }
47                 }
48             }
49         }
50
51         private static bool _SimplifyLimitOperations = false;
52         internal static bool SimplifyLimitOperations
53         {
54             get
55             {
56                 EnsureSettingsLoaded();
57                 return _SimplifyLimitOperations;
58             }
59         }
60
61         private static bool _SimplifyUserSpecifiedViews = true;
62         internal static bool SimplifyUserSpecifiedViews
63         {
64             get
65             {
66                 EnsureSettingsLoaded();
67                 return _SimplifyUserSpecifiedViews;
68             }
69         }
70     }
71 }