示例#1
0
 public static string?GetGlobalInfo(GlobalInfoKey key)
 {
     lock (_globalInfoTableLock)
     {
         _globalInfoTable.TryGetValue(key, out var result);
         return(result);
     }
 }
示例#2
0
 public static void SetGlobalInfo(GlobalInfoKey key, string?value)
 {
     lock (_globalInfoTableLock)
     {
         if (string.IsNullOrEmpty(value))
         {
             _globalInfoTable.Remove(key);
         }
         else
         {
             _globalInfoTable[key] = value !;
         }
     }
 }
示例#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));
        }
示例#4
0
 public GlobalInfoChangedEventArgs(GlobalInfoKey key, string?value)
 {
     Key   = key;
     Value = value;
 }