Xamarin Public Jenkins (auto-signing) e79aa3c0ed Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
2016-08-03 10:59:49 +00:00

56 lines
2.2 KiB
C#

//------------------------------------------------------------------------------
// <copyright file="AppSettings.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Xml.Serialization {
using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Security.Permissions;
internal static class AppSettings {
private const string UseLegacySerializerGenerationAppSettingsString = "System:Xml:Serialization:UseLegacySerializerGeneration";
private static bool? useLegacySerializerGeneration;
private static volatile bool settingsInitalized = false;
private static object appSettingsLock = new object();
internal static bool? UseLegacySerializerGeneration {
get {
EnsureSettingsLoaded();
return useLegacySerializerGeneration;
}
}
static void EnsureSettingsLoaded() {
#if CONFIGURATION_DEP
if (!settingsInitalized) {
lock (appSettingsLock) {
if (!settingsInitalized) {
NameValueCollection appSettingsSection = null;
try {
appSettingsSection = ConfigurationManager.AppSettings;
}
catch (ConfigurationErrorsException) {
}
finally {
bool tempUseLegacySerializerGeneration;
if ((appSettingsSection == null) || !bool.TryParse(appSettingsSection[UseLegacySerializerGenerationAppSettingsString], out tempUseLegacySerializerGeneration)) {
useLegacySerializerGeneration = null;
}
else {
useLegacySerializerGeneration = (bool?)tempUseLegacySerializerGeneration;
}
settingsInitalized = true;
}
}
}
}
#endif
}
}
}