Example #1
0
        internal static void LogSwitchValues(RuntimeEventSource ev)
        {
            if (s_switches is not null)
            {
                lock (s_switches)
                {
                    foreach (KeyValuePair <string, bool> kvp in s_switches)
                    {
                        // Convert bool to int because it's cheaper to log (no boxing)
                        ev.LogAppContextSwitch(kvp.Key, kvp.Value ? 1 : 0);
                    }
                }
            }

            if (s_dataStore is not null)
            {
                lock (s_dataStore)
                {
                    if (s_switches is not null)
                    {
                        lock (s_switches)
                        {
                            LogDataStore(ev, s_switches);
                        }
                    }
                    else
                    {
                        LogDataStore(ev, null);
                    }
Example #2
0
 static void LogDataStore(RuntimeEventSource ev, Dictionary <string, bool>?switches)
 {
     Debug.Assert(s_dataStore is not null);
     foreach (KeyValuePair <string, object?> kvp in s_dataStore)
     {
         if (kvp.Value is string s &&
             bool.TryParse(s, out bool isEnabled) &&
             switches?.ContainsKey(kvp.Key) != true)
         {
             ev.LogAppContextSwitch(kvp.Key, isEnabled ? 1 : 0);
         }
     }
 }
Example #3
0
 public static void Initialize()
 {
     s_RuntimeEventSource = new RuntimeEventSource();
 }