LocalAppContextSwitches
using System.Runtime.CompilerServices;
namespace System
{
[NullableContext(1)]
[Nullable(0)]
internal static class LocalAppContextSwitches
{
private static int s_dontSupportPngFramesInIcons;
private static int s_optimizePrintPreview;
public static bool DontSupportPngFramesInIcons {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get {
return GetCachedSwitchValue("Switch.System.Drawing.DontSupportPngFramesInIcons", ref s_dontSupportPngFramesInIcons);
}
}
public static bool OptimizePrintPreview {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get {
return GetCachedSwitchValue("Switch.System.Drawing.Printing.OptimizePrintPreview", ref s_optimizePrintPreview);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool GetSwitchValue(string switchName, ref bool switchValue)
{
return AppContext.TryGetSwitch(switchName, out switchValue);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool GetCachedSwitchValue(string switchName, ref int cachedSwitchValue)
{
int num = cachedSwitchValue;
if (num < 0)
return false;
if (num > 0)
return true;
return GetCachedSwitchValueInternal(switchName, ref cachedSwitchValue);
}
private static bool GetCachedSwitchValueInternal(string switchName, ref int cachedSwitchValue)
{
bool isEnabled;
bool flag = AppContext.TryGetSwitch(switchName, out isEnabled);
if (!flag)
isEnabled = false;
AppContext.TryGetSwitch("TestSwitch.LocalAppContext.DisableCaching", out bool isEnabled2);
if (!isEnabled2)
cachedSwitchValue = (isEnabled ? 1 : (-1));
else if (!flag) {
AppContext.SetSwitch(switchName, isEnabled);
}
return isEnabled;
}
}
}