コード例 #1
0
 /// <summary>Clears the content of current logical context.</summary>
 /// <param name="free">Free the full slot.</param>
 public static void Clear(bool free)
 {
     if (free)
     {
         MappedDiagnosticsLogicalContext.SetThreadLocal((IDictionary <string, object>)null);
     }
     else
     {
         MappedDiagnosticsLogicalContext.GetLogicalThreadDictionary(true).Clear();
     }
 }
コード例 #2
0
 /// <summary>
 /// Gets the current logical context named item, as <see cref="T:System.Object" />.
 /// </summary>
 /// <param name="item">Item name.</param>
 /// <returns>The value of <paramref name="item" />, if defined; otherwise <c>null</c>.</returns>
 public static object GetObject(string item)
 {
     MappedDiagnosticsLogicalContext.GetLogicalThreadDictionary(false).TryGetValue(item, out var obj);
     return(obj);
 }
コード例 #3
0
 /// <summary>
 /// Removes the specified <paramref name="item" /> from current logical context.
 /// </summary>
 /// <param name="item">Item name.</param>
 public static void Remove(string item)
 {
     MappedDiagnosticsLogicalContext.GetLogicalThreadDictionary(true).Remove(item);
 }
コード例 #4
0
 /// <summary>
 /// Checks whether the specified <paramref name="item" /> exists in current logical context.
 /// </summary>
 /// <param name="item">Item name.</param>
 /// <returns>A boolean indicating whether the specified <paramref name="item" /> exists in current logical context.</returns>
 public static bool Contains(string item)
 {
     return(MappedDiagnosticsLogicalContext.GetLogicalThreadDictionary(false).ContainsKey(item));
 }
コード例 #5
0
 /// <summary>Returns all item names</summary>
 /// <returns>A collection of the names of all items in current logical context.</returns>
 public static ICollection <string> GetNames()
 {
     return(MappedDiagnosticsLogicalContext.GetLogicalThreadDictionary(false).Keys);
 }
コード例 #6
0
 /// <summary>
 /// Sets the current logical context item to the specified value.
 /// </summary>
 /// <param name="item">Item name.</param>
 /// <param name="value">Item value.</param>
 public static void Set(string item, object value)
 {
     MappedDiagnosticsLogicalContext.GetLogicalThreadDictionary(true)[item] = value;
 }