Example #1
0
 public void Set(string name, object value)
 {
     if (Thread.CurrentPrincipal is HttpContextPrincipal principal)
     {
         principal.Items[name] = value;
     }
     else
     {
         if (!(CallContext.LogicalGetData(LogicalDataKeys) is HashSet <string> keys))
         {
             keys = new HashSet <string>();
             CallContext.LogicalSetData(LogicalDataKeys, keys);
         }
         keys.Add(name);
         CallContext.LogicalSetData(name, value);
     }
 }
Example #2
0
 public void Set(string name, object value)
 {
     if (Thread.CurrentPrincipal is ThreadedPrincipal principal)
     {
         principal.Items[name] = value;
     }
     else
     {
         var keys = CallContext.LogicalGetData("$$keys") as HashSet <string>;
         if (keys == null)
         {
             keys = new HashSet <string>();
             CallContext.LogicalSetData("$$keys", keys);
         }
         keys.Add(name);
         CallContext.LogicalSetData(name, value);
     }
 }