9using System.Security.Principal;
10using System.Threading;
22 private const string _localContextName =
"Csla.LocalContext";
23 private const string _clientContextName =
"Csla.ClientContext";
24 private const string _globalContextName =
"Csla.GlobalContext";
40 IPrincipal result = Thread.CurrentPrincipal;
43 result =
new System.Security.Claims.ClaimsPrincipal();
53 public virtual void SetUser(IPrincipal principal)
55 Thread.CurrentPrincipal = principal;
63 LocalDataStoreSlot slot = Thread.GetNamedDataSlot(_localContextName);
73 LocalDataStoreSlot slot = Thread.GetNamedDataSlot(_localContextName);
74 Thread.SetData(slot, localContext);
82 if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
88 LocalDataStoreSlot slot = Thread.GetNamedDataSlot(_clientContextName);
99 if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
101 AppDomain.CurrentDomain.SetData(_clientContextName, clientContext);
105 LocalDataStoreSlot slot = Thread.GetNamedDataSlot(_clientContextName);
106 Thread.SetData(slot, clientContext);
115 LocalDataStoreSlot slot = Thread.GetNamedDataSlot(_globalContextName);
125 LocalDataStoreSlot slot = Thread.GetNamedDataSlot(_globalContextName);
126 Thread.SetData(slot, globalContext);
129 private static IServiceProvider _provider;
145 _provider = serviceProvider;
152#pragma warning disable CS3002
154#pragma warning restore CS3002
163#pragma warning disable CS3001
165#pragma warning restore CS3001
Context manager for the user property and local/client/global context dictionaries that uses thread l...
IServiceProvider GetDefaultServiceProvider()
Gets the default IServiceProvider
ContextDictionary GetGlobalContext()
Gets the global context dictionary.
void SetServiceProvider(IServiceProvider scope)
Sets the service provider for current scope
void SetLocalContext(ContextDictionary localContext)
Sets the local context dictionary.
virtual IPrincipal GetUser()
Gets the current user principal.
IServiceProvider GetServiceProvider()
Gets the service provider for current scope
virtual void SetUser(IPrincipal principal)
Sets the current user principal.
bool IsValid
Returns a value indicating whether the context is valid.
void SetDefaultServiceProvider(IServiceProvider serviceProvider)
Sets the default IServiceProvider
ContextDictionary GetLocalContext()
Gets the local context dictionary.
void SetClientContext(ContextDictionary clientContext)
Sets the client context dictionary.
void SetGlobalContext(ContextDictionary globalContext)
Sets the global context dictionary.
ContextDictionary GetClientContext()
Gets the client context dictionary.
Dictionary type that is serializable with the SerializationFormatterFactory.GetFormatter().
Defines the interface for an application context manager type.