Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
LocalAppContextSwitches.cs
Go to the documentation of this file.
2
3namespace System;
4
5internal static class LocalAppContextSwitches
6{
8
9 private static int s_ignoreEmptyKeySequences;
10
12
13 private static int s_limitXPathComplexity;
14
15 private static int s_allowDefaultResolver;
16
18 {
19 [MethodImpl(MethodImplOptions.AggressiveInlining)]
20 get
21 {
22 return GetCachedSwitchValue("Switch.System.Xml.DontThrowOnInvalidSurrogatePairs", ref s_dontThrowOnInvalidSurrogatePairs);
23 }
24 }
25
26 public static bool IgnoreEmptyKeySequences
27 {
28 [MethodImpl(MethodImplOptions.AggressiveInlining)]
29 get
30 {
31 return GetCachedSwitchValue("Switch.System.Xml.IgnoreEmptyKeySequencess", ref s_ignoreEmptyKeySequences);
32 }
33 }
34
36 {
37 [MethodImpl(MethodImplOptions.AggressiveInlining)]
38 get
39 {
40 return GetCachedSwitchValue("Switch.System.Xml.IgnoreKindInUtcTimeSerialization", ref s_ignoreKindInUtcTimeSerialization);
41 }
42 }
43
44 public static bool LimitXPathComplexity
45 {
46 [MethodImpl(MethodImplOptions.AggressiveInlining)]
47 get
48 {
49 return GetCachedSwitchValue("Switch.System.Xml.LimitXPathComplexity", ref s_limitXPathComplexity);
50 }
51 }
52
53 public static bool AllowDefaultResolver
54 {
55 [MethodImpl(MethodImplOptions.AggressiveInlining)]
56 get
57 {
58 return GetCachedSwitchValue("Switch.System.Xml.AllowDefaultResolver", ref s_allowDefaultResolver);
59 }
60 }
61
62 [MethodImpl(MethodImplOptions.AggressiveInlining)]
63 internal static bool GetCachedSwitchValue(string switchName, ref int cachedSwitchValue)
64 {
65 if (cachedSwitchValue < 0)
66 {
67 return false;
68 }
69 if (cachedSwitchValue > 0)
70 {
71 return true;
72 }
73 return GetCachedSwitchValueInternal(switchName, ref cachedSwitchValue);
74 }
75
76 private static bool GetCachedSwitchValueInternal(string switchName, ref int cachedSwitchValue)
77 {
78 if (!AppContext.TryGetSwitch(switchName, out var isEnabled))
79 {
80 isEnabled = GetSwitchDefaultValue(switchName);
81 }
82 AppContext.TryGetSwitch("TestSwitch.LocalAppContext.DisableCaching", out var isEnabled2);
83 if (!isEnabled2)
84 {
85 cachedSwitchValue = (isEnabled ? 1 : (-1));
86 }
87 return isEnabled;
88 }
89
90 private static bool GetSwitchDefaultValue(string switchName)
91 {
92 if (switchName == "Switch.System.Runtime.Serialization.SerializationGuard")
93 {
94 return true;
95 }
96 if (switchName == "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization")
97 {
98 return true;
99 }
100 return false;
101 }
102}
static bool TryGetSwitch(string switchName, out bool isEnabled)
Definition AppContext.cs:74
static bool GetSwitchDefaultValue(string switchName)
static bool GetCachedSwitchValue(string switchName, ref int cachedSwitchValue)
static bool GetCachedSwitchValueInternal(string switchName, ref int cachedSwitchValue)