8using System.Security.Principal;
19 private readonly AsyncLocal<ContextDictionary> _localContext =
new();
20 private readonly AsyncLocal<ContextDictionary> _clientContext =
new();
21 private readonly AsyncLocal<IPrincipal> _principal =
new();
43 IPrincipal result = _principal.Value;
46 result =
new System.Security.Claims.ClaimsPrincipal();
56 public virtual void SetUser(IPrincipal principal)
58 _principal.Value = 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.
Application context manager using AsyncLocal for user and context dictionaries.
virtual void OnApplicationContextSet()
Method called when the ApplicationContext property has been set to a new value.
bool IsStatefulContext
Gets a value indicating whether the context manager is stateful.
void SetLocalContext(ContextDictionary localContext)
Sets the local context dictionary.
ContextDictionary GetClientContext(ApplicationContext.ExecutionLocations executionLocation)
Gets the client context dictionary.
bool IsValid
Returns a value indicating whether the context is valid.
ContextDictionary GetLocalContext()
Gets the local context dictionary.
virtual IPrincipal GetUser()
Gets the current user principal.
void SetClientContext(ContextDictionary clientContext, ApplicationContext.ExecutionLocations executionLocation)
Sets the client context dictionary.
virtual void SetUser(IPrincipal principal)
Sets the current user principal.
Dictionary type that is serializable with the SerializationFormatterFactory.GetFormatter().
Subtype of IContextManager for use by LocalProxy.