CSLA.NET 5.4.2
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
ApplicationContextManagerStatic.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="ApplicationContextManagerStatic.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Default context manager for the user property</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Security.Principal;
10using System.Security.Claims;
11
12namespace Csla.Core
13{
21 {
25 public bool IsValid => true;
26
27 private static ContextDictionary currentLocalContext = new ContextDictionary();
28 private static ContextDictionary currentClientContext = new ContextDictionary();
29 private static ContextDictionary currentGlobalContext = new ContextDictionary();
30 private static IPrincipal currentPrincipal = new ClaimsPrincipal();
31 private static IServiceProvider currentDefaultServiceProvider;
32 private static IServiceProvider currentServiceProvider;
33
38 {
39 return currentClientContext;
40 }
41
45 public IServiceProvider GetDefaultServiceProvider()
46 {
47 return currentDefaultServiceProvider;
48 }
49
54 {
55 return currentGlobalContext;
56 }
57
62 {
63 return currentLocalContext;
64 }
65
70 public IPrincipal GetUser()
71 {
72 return currentPrincipal;
73 }
74
79 public void SetClientContext(ContextDictionary clientContext)
80 {
81 currentClientContext = clientContext;
82 }
83
88 public void SetDefaultServiceProvider(IServiceProvider serviceProvider)
89 {
90 currentDefaultServiceProvider = serviceProvider;
91 }
92
97 public void SetGlobalContext(ContextDictionary globalContext)
98 {
99 currentGlobalContext = globalContext;
100 }
101
106 public void SetLocalContext(ContextDictionary localContext)
107 {
108 currentLocalContext = localContext;
109 }
110
114 public IServiceProvider GetServiceProvider()
115 {
116 return currentServiceProvider ?? GetDefaultServiceProvider();
117 }
118
123 public void SetServiceProvider(IServiceProvider scope)
124 {
125 currentServiceProvider = scope;
126 }
127
132 public void SetUser(IPrincipal principal)
133 {
134 currentPrincipal = principal;
135 }
136 }
137}
Context manager for the user property and local/client/global context dictionaries that uses static f...
void SetUser(IPrincipal principal)
Sets the current user principal.
void SetGlobalContext(ContextDictionary globalContext)
Sets the global context dictionary.
void SetClientContext(ContextDictionary clientContext)
Sets the client context dictionary.
IServiceProvider GetDefaultServiceProvider()
Gets the default IServiceProvider
ContextDictionary GetLocalContext()
Gets the local context dictionary.
void SetLocalContext(ContextDictionary localContext)
Sets the local context dictionary.
ContextDictionary GetGlobalContext()
Gets the global context dictionary.
IPrincipal GetUser()
Gets the current user principal.
void SetServiceProvider(IServiceProvider scope)
Sets the service provider for current scope
IServiceProvider GetServiceProvider()
Gets the service provider for current scope
bool IsValid
Returns a value indicating whether the context is valid.
ContextDictionary GetClientContext()
Gets the client context dictionary.
void SetDefaultServiceProvider(IServiceProvider serviceProvider)
Sets the default IServiceProvider
Dictionary type that is serializable with the SerializationFormatterFactory.GetFormatter().
Defines the interface for an application context manager type.