9using System.Security.Principal;
10using System.Threading;
20 private readonly AsyncLocal<ContextDictionary> _localContext =
new();
21 private readonly AsyncLocal<ContextDictionary> _clientContext =
new();
43 IPrincipal result = Thread.CurrentPrincipal;
46 result =
new System.Security.Claims.ClaimsPrincipal();
56 public virtual void SetUser(IPrincipal principal)
58 Thread.CurrentPrincipal = principal;
66 return _localContext.Value;
75 _localContext.Value = localContext;
84 return _clientContext.Value;
94 _clientContext.Value = clientContext;
97 private readonly AsyncLocal<ApplicationContext> _applicationContext =
new();
106 return _applicationContext.Value;
110 _applicationContext.Value = value;
Provides consistent context information between the client and server DataPortal objects.
ExecutionLocations
Enum representing the locations code can execute.
Default context manager for the user property and local/client/global context dictionaries.
void SetLocalContext(ContextDictionary localContext)
Sets the local context dictionary.
bool IsStatefulContext
Gets a value indicating whether the context manager is stateful.
ContextDictionary GetClientContext(ApplicationContext.ExecutionLocations executionLocation)
Gets the client context dictionary.
virtual IPrincipal GetUser()
Gets the current user principal.
virtual void SetUser(IPrincipal principal)
Sets the current user principal.
virtual void OnApplicationContextSet()
Method called when the ApplicationContext property has been set to a new value.
bool IsValid
Returns a value indicating whether the context is valid.
void SetClientContext(ContextDictionary clientContext, ApplicationContext.ExecutionLocations executionLocation)
Sets the client context dictionary.
ContextDictionary GetLocalContext()
Gets the local context dictionary.
Dictionary type that is serializable with the SerializationFormatterFactory.GetFormatter().
Defines the interface for an application context manager type.