Exemplo n.º 1
0
 public static string?GetGlobalInfo(GlobalInfoKey key)
 {
     lock (_globalInfoTableLock)
     {
         _globalInfoTable.TryGetValue(key, out var result);
         return(result);
     }
 }
Exemplo n.º 2
0
 public static void SetGlobalInfo(GlobalInfoKey key, string?value)
 {
     lock (_globalInfoTableLock)
     {
         if (string.IsNullOrEmpty(value))
         {
             _globalInfoTable.Remove(key);
         }
         else
         {
             _globalInfoTable[key] = value !;
         }
     }
 }
Exemplo n.º 3
0
        public static void SetGlobalInfo(GlobalInfoKey key, string?value)
        {
            lock (_globalInfoTableLock)
            {
                if (string.IsNullOrEmpty(value))
                {
                    _globalInfoTable.Remove(key);
                }
                else
                {
                    _globalInfoTable[key] = value !;
                }
            }

            // Triggering the event outside of the lock to avoid potential deadlock
            // if the handler will cause another change of a global state.

            // null sender is a common case for static events.
            GlobalInfoChanged?.Invoke(sender: null, new GlobalInfoChangedEventArgs(key, value));
        }
Exemplo n.º 4
0
 public GlobalInfoChangedEventArgs(GlobalInfoKey key, string?value)
 {
     Key   = key;
     Value = value;
 }