Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.ServiceModel / System / ServiceModel / LocalAppContextSwitches.cs
1 // <copyright>
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 // </copyright>
4 namespace System.ServiceModel
5 {
6     using System;
7     using System.Runtime.CompilerServices;
8
9     // When adding a quirk, name it such that false is new behavior and true is old behavior.
10     // You are opting IN to old behavior. The new behavior is default.
11     // For example, we want to enable the functionality to explicitly add a connection close header
12     // in 4.6 and above. So we set DisableExplicitConnectionCloseHeader to true if running 4.5.2 or less.
13     internal static class LocalAppContextSwitches
14     {
15         private const string DisableExplicitConnectionCloseHeaderString = "Switch.System.ServiceModel.DisableExplicitConnectionCloseHeader";
16         private const string AllowUnsignedToHeaderString = "Switch.System.ServiceModel.AllowUnsignedToHeader";
17         private const string DisableCngCertificatesString = "Switch.System.ServiceModel.DisableCngCertificates";
18         internal const string DisableUsingServicePointManagerSecurityProtocolsString = "Switch.System.ServiceModel.DisableUsingServicePointManagerSecurityProtocols";
19
20         private static int disableExplicitConnectionCloseHeader;
21         private static int allowUnsignedToHeader;
22         private static int disableCngCertificates;
23         private static int disableUsingServicePointManagerSecurityProtocols;
24
25         public static bool DisableExplicitConnectionCloseHeader
26         {
27             [MethodImpl(MethodImplOptions.AggressiveInlining)]
28             get
29             {
30                 return LocalAppContext.GetCachedSwitchValue(DisableExplicitConnectionCloseHeaderString, ref disableExplicitConnectionCloseHeader);
31             }
32         }
33
34         public static bool AllowUnsignedToHeader
35         {
36             [MethodImpl(MethodImplOptions.AggressiveInlining)]
37             get
38             {
39                 return LocalAppContext.GetCachedSwitchValue(AllowUnsignedToHeaderString, ref allowUnsignedToHeader);
40             }
41         }
42
43         public static bool DisableCngCertificates
44         {
45             [MethodImpl(MethodImplOptions.AggressiveInlining)]
46             get
47             {
48                 return LocalAppContext.GetCachedSwitchValue(DisableCngCertificatesString, ref disableCngCertificates);
49             }
50         }
51
52         public static bool DisableUsingServicePointManagerSecurityProtocols
53         {
54             [MethodImpl(MethodImplOptions.AggressiveInlining)]
55             get
56             {
57                 return LocalAppContext.GetCachedSwitchValue(DisableUsingServicePointManagerSecurityProtocolsString, ref disableUsingServicePointManagerSecurityProtocols);
58             }
59         }
60
61         public static void SetDefaultsLessOrEqual_452()
62         {
63 #pragma warning disable BCL0012            
64             // Define the switches that should be true for 4.5.2 or less, false for 4.6+.
65             LocalAppContext.DefineSwitchDefault(DisableExplicitConnectionCloseHeaderString, true);
66 #pragma warning restore BCL0012
67         }
68
69         public static void SetDefaultsLessOrEqual_461()
70         {
71 #pragma warning disable BCL0012            
72             // Define the switches that should be true for 4.6.1 or less, false for 4.6.2+.
73             LocalAppContext.DefineSwitchDefault(DisableCngCertificatesString, true);
74 #pragma warning restore BCL0012
75         }
76     }
77 }