9using System.Security.Principal;
11using System.Security.Claims;
13using System.ComponentModel;
95 private readonly
object _syncContext =
new();
245#if (ANDROID || IOS || NETFX_CORE) && !NETSTANDARD
257 get {
return _executionLocation; }
262 _executionLocation = location;
308 {
get;
internal set; } = System.Transactions.TransactionScopeAsyncFlowOption.Suppress;
312 #region Logical Execution Location
340 if (location !=
null)
376 [EditorBrowsable(EditorBrowsableState.Advanced)]
387 [EditorBrowsable(EditorBrowsableState.Advanced)]
390 if (CurrentServiceProvider ==
null)
391 throw new NullReferenceException(nameof(CurrentServiceProvider));
393 var result = CurrentServiceProvider.GetRequiredService<T>();
402 [EditorBrowsable(EditorBrowsableState.Advanced)]
405 if (CurrentServiceProvider ==
null)
406 throw new NullReferenceException(nameof(CurrentServiceProvider));
408 return CurrentServiceProvider.GetRequiredService(serviceType);
418 [EditorBrowsable(EditorBrowsableState.Advanced)]
422 if (CurrentServiceProvider !=
null)
423 result = ActivatorUtilities.CreateInstance(CurrentServiceProvider, objectType, parameters);
425 result = Activator.CreateInstance(objectType, parameters);
428 tmp.ApplicationContext =
this;
440 internal object CreateGenericInstanceDI(Type type, params Type[] paramTypes)
442 var genericType = type.GetGenericTypeDefinition();
443 var gt = genericType.MakeGenericType(paramTypes);
452 [EditorBrowsable(EditorBrowsableState.Advanced)]
463 [EditorBrowsable(EditorBrowsableState.Advanced)]
467 result = Activator.CreateInstance(objectType, parameters);
470 tmp.ApplicationContext =
this;
481 internal object CreateGenericInstance(Type type, params Type[] paramTypes)
483 var genericType = type.GetGenericTypeDefinition();
484 var gt = genericType.MakeGenericType(paramTypes);
Provides consistent context information between the client and server DataPortal objects.
LogicalExecutionLocations LogicalExecutionLocation
Return Logical Execution Location - Client or Server This is applicable to Local mode as well
object GetRequiredService(Type serviceType)
Attempts to get service via DI using ServiceProviderServiceExtensions.GetRequiredService.
ExecutionLocations ExecutionLocation
Returns a value indicating whether the application code is currently executing on the client or serve...
ExecutionLocations
Enum representing the locations code can execute.
static bool UseReflectionFallback
Gets or sets a value indicating whether CSLA should fallback to using reflection instead of System....
static bool AutoCloneOnUpdate
Gets a value indicating whether objects should be automatically cloned by the data portal Update() me...
LogicalExecutionLocations
Enum representing the logical execution location The setting is set to server when server is execting...
static Type SerializationFormatter
Gets the serialization formatter type used by CSLA .NET for all explicit object serialization (such a...
bool IsOffline
Gets or sets a value indicating whether the app should be considered "offline".
IContextManager ContextManager
Gets the context manager responsible for storing user and context information for the application.
object CreateInstanceDI(Type objectType, params object[] parameters)
Creates an object using 'Activator.CreateInstance' using service provider (if one is available) to po...
static PropertyChangedModes PropertyChangedMode
Gets or sets a value specifying how CSLA .NET should raise PropertyChanged events.
void Clear()
Clears all context collections.
bool IsAStatefulContextManager
Gets a value indicating whether the current context manager is used in a stateful context (e....
static int DefaultTransactionTimeoutInSeconds
Gets or sets the default transaction timeout in seconds.
PropertyChangedModes
Enum representing the way in which CSLA .NET should raise PropertyChanged events.
string? RuleSet
Gets or sets the RuleSet name to use for static HasPermission calls.
static bool DataPortalReturnObjectOnException
Gets a value indicating whether the server-side business object should be returned to the client as p...
T CreateInstanceDI< T >(params object[] parameters)
Creates an object using 'Activator.CreateInstance' using service provider (if one is available) to po...
ApplicationContext(ApplicationContextAccessor applicationContextAccessor)
Creates a new instance of the type
static string AuthenticationType
Gets the authentication type being used by the CSLA .NET framework.
IPrincipal User
Get or set the current IPrincipal object representing the user's identity.
object CreateInstance(Type objectType, params object[] parameters)
Creates an object using Activator.
T CreateInstance< T >(params object[] parameters)
Creates an object using Activator.
ClaimsPrincipal Principal
Get or set the current ClaimsPrincipal object representing the user's identity.
ContextDictionary ClientContext
Returns the application-specific context data provided by the client.
const string DefaultRuleSet
The default RuleSet name
ContextDictionary LocalContext
Returns the application-specific context data that is local to the current AppDomain.
T GetRequiredService< T >()
Attempts to get service via DI using ServiceProviderServiceExtensions.GetRequiredService.
static string VersionRoutingTag
Gets a value representing the application version for use in server-side data portal routing.
static System.Transactions.TransactionScopeAsyncFlowOption DefaultTransactionAsyncFlowOption
Gets or sets the default transaction async flow option used to create new TransactionScope objects.
static TransactionIsolationLevel DefaultTransactionIsolationLevel
Gets or sets the default transaction isolation level.
Provides access to the correct current application context manager instance depending on runtime envi...
IContextManager GetContextManager()
Gets a reference to the correct current application context manager instance depending on runtime env...
Dictionary type that is serializable with the SerializationFormatterFactory.GetFormatter().
object GetValueOrNull(string key)
Get a value from the dictionary, or return null if the key is not found in the dictionary.
Defines the interface for an application context manager type.
ApplicationContext ApplicationContext
Gets or sets a reference to the current ApplicationContext.
IPrincipal GetUser()
Gets the current principal.
bool IsStatefulContext
Gets a value indicating whether this context manager is used in a stateful context (e....
void SetClientContext(ContextDictionary clientContext, ApplicationContext.ExecutionLocations executionLocation)
Sets the client context.
void SetUser(IPrincipal principal)
Sets the current principal.
void SetLocalContext(ContextDictionary localContext)
Sets the local context.
ContextDictionary GetClientContext(ApplicationContext.ExecutionLocations executionLocation)
Gets the client context.
ContextDictionary GetLocalContext()
Gets the local context.
Implement if a class requires access to the CSLA ApplicationContext type.
@ Serialization
The object is being serialized for a clone or data portal operation.
TransactionIsolationLevel
Specifies an isolation level for transactions controlled by TransactionalAttribute