CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
Csla.ApplicationContext Class Reference

Provides consistent context information between the client and server DataPortal objects. More...

Public Types

enum  ExecutionLocations { Client , Server }
 Enum representing the locations code can execute. More...
 
enum  PropertyChangedModes { Windows , Xaml }
 Enum representing the way in which CSLA .NET should raise PropertyChanged events. More...
 
enum  LogicalExecutionLocations { Client , Server }
 Enum representing the logical execution location The setting is set to server when server is execting a CRUD opertion, otherwise the setting is always client More...
 

Public Member Functions

 ApplicationContext (ApplicationContextAccessor applicationContextAccessor)
 Creates a new instance of the type More...
 
void Clear ()
 Clears all context collections. More...
 
CreateInstanceDI< T > (params object[] parameters)
 Creates an object using 'Activator.CreateInstance' using service provider (if one is available) to populate any parameters in CTOR that are not manually passed in. More...
 
GetRequiredService< T > ()
 Attempts to get service via DI using ServiceProviderServiceExtensions.GetRequiredService. More...
 
object GetRequiredService (Type serviceType)
 Attempts to get service via DI using ServiceProviderServiceExtensions.GetRequiredService. More...
 
object CreateInstanceDI (Type objectType, params object[] parameters)
 Creates an object using 'Activator.CreateInstance' using service provider (if one is available) to populate any parameters in CTOR that are not manually passed in. More...
 
CreateInstance< T > (params object[] parameters)
 Creates an object using Activator. More...
 
object CreateInstance (Type objectType, params object[] parameters)
 Creates an object using Activator. More...
 

Static Public Attributes

const string DefaultRuleSet = "default"
 The default RuleSet name More...
 

Properties

IContextManager ContextManager [get]
 Gets the context manager responsible for storing user and context information for the application. More...
 
ClaimsPrincipal Principal [getset]
 Get or set the current ClaimsPrincipal object representing the user's identity. More...
 
IPrincipal User [getset]
 Get or set the current IPrincipal object representing the user's identity. More...
 
ContextDictionary LocalContext [get]
 Returns the application-specific context data that is local to the current AppDomain. More...
 
ContextDictionary ClientContext [get]
 Returns the application-specific context data provided by the client. More...
 
bool IsOffline [getset]
 Gets or sets a value indicating whether the app should be considered "offline". More...
 
static bool UseReflectionFallback = false [getset]
 Gets or sets a value indicating whether CSLA should fallback to using reflection instead of System.Linq.Expressions (true, default). More...
 
static string VersionRoutingTag [getset]
 Gets a value representing the application version for use in server-side data portal routing. More...
 
static string AuthenticationType = "Csla" [getset]
 Gets the authentication type being used by the CSLA .NET framework. More...
 
static bool AutoCloneOnUpdate = true [getset]
 Gets a value indicating whether objects should be automatically cloned by the data portal Update() method when using a local data portal configuration. More...
 
static bool DataPortalReturnObjectOnException [getset]
 Gets a value indicating whether the server-side business object should be returned to the client as part of the DataPortalException (default is false). More...
 
static Type SerializationFormatter = typeof(Serialization.Mobile.MobileFormatter) [getset]
 Gets the serialization formatter type used by CSLA .NET for all explicit object serialization (such as cloning, n-level undo, etc). More...
 
static PropertyChangedModes PropertyChangedMode [getset]
 Gets or sets a value specifying how CSLA .NET should raise PropertyChanged events. More...
 
ExecutionLocations ExecutionLocation [get]
 Returns a value indicating whether the application code is currently executing on the client or server. More...
 
string? RuleSet [getset]
 Gets or sets the RuleSet name to use for static HasPermission calls. More...
 
static TransactionIsolationLevel DefaultTransactionIsolationLevel = TransactionIsolationLevel.Unspecified [getset]
 Gets or sets the default transaction isolation level. More...
 
static int DefaultTransactionTimeoutInSeconds = 30 [getset]
 Gets or sets the default transaction timeout in seconds. More...
 
static System.Transactions.TransactionScopeAsyncFlowOption DefaultTransactionAsyncFlowOption = System.Transactions.TransactionScopeAsyncFlowOption.Suppress [getset]
 Gets or sets the default transaction async flow option used to create new TransactionScope objects. More...
 
LogicalExecutionLocations LogicalExecutionLocation [get]
 Return Logical Execution Location - Client or Server This is applicable to Local mode as well More...
 
bool IsAStatefulContextManager [get]
 Gets a value indicating whether the current context manager is used in a stateful context (e.g. More...
 

Detailed Description

Provides consistent context information between the client and server DataPortal objects.

Definition at line 21 of file ApplicationContext.cs.

Member Enumeration Documentation

◆ ExecutionLocations

Enum representing the locations code can execute.

Enumerator
Client 

The code is executing on the client.

Server 

The code is executing on the application server.

Definition at line 201 of file ApplicationContext.cs.

◆ LogicalExecutionLocations

Enum representing the logical execution location The setting is set to server when server is execting a CRUD opertion, otherwise the setting is always client

Enumerator
Client 

The code is executing on the client.

Server 

The code is executing on the server.

This includes Local mode execution

Definition at line 318 of file ApplicationContext.cs.

◆ PropertyChangedModes

Enum representing the way in which CSLA .NET should raise PropertyChanged events.

Enumerator
Windows 

Raise PropertyChanged events as required by Windows Forms data binding.

Xaml 

Raise PropertyChanged events as required by XAML data binding in WPF.

Definition at line 230 of file ApplicationContext.cs.

Constructor & Destructor Documentation

◆ ApplicationContext()

Csla.ApplicationContext.ApplicationContext ( ApplicationContextAccessor  applicationContextAccessor)

Creates a new instance of the type

Parameters
applicationContextAccessor

Definition at line 27 of file ApplicationContext.cs.

Member Function Documentation

◆ Clear()

void Csla.ApplicationContext.Clear ( )

Clears all context collections.

Definition at line 142 of file ApplicationContext.cs.

◆ CreateInstance()

object Csla.ApplicationContext.CreateInstance ( Type  objectType,
params object[]  parameters 
)

Creates an object using Activator.

Parameters
objectTypeType of object to create
parametersParameters for constructor

Definition at line 464 of file ApplicationContext.cs.

◆ CreateInstance< T >()

T Csla.ApplicationContext.CreateInstance< T > ( params object[]  parameters)

Creates an object using Activator.

Template Parameters
TType of object to create.
Parameters
parametersParameters for constructor

Definition at line 453 of file ApplicationContext.cs.

◆ CreateInstanceDI()

object Csla.ApplicationContext.CreateInstanceDI ( Type  objectType,
params object[]  parameters 
)

Creates an object using 'Activator.CreateInstance' using service provider (if one is available) to populate any parameters in CTOR that are not manually passed in.

Parameters
objectTypeType of object to create
parametersManually passed in parameters for constructor

Definition at line 419 of file ApplicationContext.cs.

◆ CreateInstanceDI< T >()

T Csla.ApplicationContext.CreateInstanceDI< T > ( params object[]  parameters)

Creates an object using 'Activator.CreateInstance' using service provider (if one is available) to populate any parameters in CTOR that are not manually passed in.

Template Parameters
TType of object to create.
Parameters
parametersParameters for constructor

Definition at line 377 of file ApplicationContext.cs.

◆ GetRequiredService()

object Csla.ApplicationContext.GetRequiredService ( Type  serviceType)

Attempts to get service via DI using ServiceProviderServiceExtensions.GetRequiredService.

Throws exception if service not properly registered with DI.

Parameters
serviceTypeType of service/object to create.

Definition at line 403 of file ApplicationContext.cs.

◆ GetRequiredService< T >()

Attempts to get service via DI using ServiceProviderServiceExtensions.GetRequiredService.

Throws exception if service not properly registered with DI.

Template Parameters
TType of service/object to create.

Definition at line 388 of file ApplicationContext.cs.

Member Data Documentation

◆ DefaultRuleSet

const string Csla.ApplicationContext.DefaultRuleSet = "default"
static

The default RuleSet name

Definition at line 268 of file ApplicationContext.cs.

Property Documentation

◆ AuthenticationType

string Csla.ApplicationContext.AuthenticationType = "Csla"
staticgetset

Gets the authentication type being used by the CSLA .NET framework.

Returns

Definition at line 181 of file ApplicationContext.cs.

◆ AutoCloneOnUpdate

bool Csla.ApplicationContext.AutoCloneOnUpdate = true
staticgetset

Gets a value indicating whether objects should be automatically cloned by the data portal Update() method when using a local data portal configuration.

Definition at line 188 of file ApplicationContext.cs.

◆ ClientContext

ContextDictionary Csla.ApplicationContext.ClientContext
get

Returns the application-specific context data provided by the client.

The return value is a HybridDictionary. If one does not already exist, and empty one is created and returned.

Note that data in this context is transferred from the client to the server. No data is transferred from the server to the client.

This property is thread safe in a Windows client setting and on an application server. It is not guaranteed to be thread safe within the context of an ASP.NET client setting (i.e. in your ASP.NET UI).

Definition at line 116 of file ApplicationContext.cs.

◆ ContextManager

IContextManager Csla.ApplicationContext.ContextManager
get

Gets the context manager responsible for storing user and context information for the application.

Definition at line 40 of file ApplicationContext.cs.

◆ DataPortalReturnObjectOnException

bool Csla.ApplicationContext.DataPortalReturnObjectOnException
staticgetset

Gets a value indicating whether the server-side business object should be returned to the client as part of the DataPortalException (default is false).

Definition at line 196 of file ApplicationContext.cs.

◆ DefaultTransactionAsyncFlowOption

System.Transactions.TransactionScopeAsyncFlowOption Csla.ApplicationContext.DefaultTransactionAsyncFlowOption = System.Transactions.TransactionScopeAsyncFlowOption.Suppress
staticgetset

Gets or sets the default transaction async flow option used to create new TransactionScope objects.

Definition at line 307 of file ApplicationContext.cs.

◆ DefaultTransactionIsolationLevel

TransactionIsolationLevel Csla.ApplicationContext.DefaultTransactionIsolationLevel = TransactionIsolationLevel.Unspecified
staticgetset

Gets or sets the default transaction isolation level.

The default transaction isolation level.

Definition at line 293 of file ApplicationContext.cs.

◆ DefaultTransactionTimeoutInSeconds

int Csla.ApplicationContext.DefaultTransactionTimeoutInSeconds = 30
staticgetset

Gets or sets the default transaction timeout in seconds.

The default transaction timeout in seconds.

Definition at line 301 of file ApplicationContext.cs.

◆ ExecutionLocation

ExecutionLocations Csla.ApplicationContext.ExecutionLocation
get

Returns a value indicating whether the application code is currently executing on the client or server.

Definition at line 255 of file ApplicationContext.cs.

◆ IsAStatefulContextManager

bool Csla.ApplicationContext.IsAStatefulContextManager
get

Gets a value indicating whether the current context manager is used in a stateful context (e.g.

WPF, Blazor, etc.)

Definition at line 362 of file ApplicationContext.cs.

◆ IsOffline

bool Csla.ApplicationContext.IsOffline
getset

Gets or sets a value indicating whether the app should be considered "offline".

If this value is true then the client-side data portal will direct all calls to the local data portal. No calls will flow to remote data portal endpoints.

Definition at line 160 of file ApplicationContext.cs.

◆ LocalContext

ContextDictionary Csla.ApplicationContext.LocalContext
get

Returns the application-specific context data that is local to the current AppDomain.

The return value is a HybridDictionary. If one does not already exist, and empty one is created and returned.

Note that data in this context is NOT transferred to and from the client and server.

Definition at line 81 of file ApplicationContext.cs.

◆ LogicalExecutionLocation

LogicalExecutionLocations Csla.ApplicationContext.LogicalExecutionLocation
get

Return Logical Execution Location - Client or Server This is applicable to Local mode as well

Definition at line 335 of file ApplicationContext.cs.

◆ Principal

ClaimsPrincipal Csla.ApplicationContext.Principal
getset

Get or set the current ClaimsPrincipal object representing the user's identity.

Definition at line 46 of file ApplicationContext.cs.

◆ PropertyChangedMode

PropertyChangedModes Csla.ApplicationContext.PropertyChangedMode
staticgetset

Gets or sets a value specifying how CSLA .NET should raise PropertyChanged events.

Definition at line 224 of file ApplicationContext.cs.

◆ RuleSet

string? Csla.ApplicationContext.RuleSet
getset

Gets or sets the RuleSet name to use for static HasPermission calls.

The rule set.

Definition at line 274 of file ApplicationContext.cs.

◆ SerializationFormatter

Type Csla.ApplicationContext.SerializationFormatter = typeof(Serialization.Mobile.MobileFormatter)
staticgetset

Gets the serialization formatter type used by CSLA .NET for all explicit object serialization (such as cloning, n-level undo, etc).

Definition at line 218 of file ApplicationContext.cs.

◆ User

IPrincipal Csla.ApplicationContext.User
getset

Get or set the current IPrincipal object representing the user's identity.

This is discussed in Chapter 5. When running under IIS the HttpContext.Current.User value is used, otherwise the current Thread.CurrentPrincipal value is used.

Definition at line 62 of file ApplicationContext.cs.

◆ UseReflectionFallback

bool Csla.ApplicationContext.UseReflectionFallback = false
staticgetset

Gets or sets a value indicating whether CSLA should fallback to using reflection instead of System.Linq.Expressions (true, default).

Definition at line 167 of file ApplicationContext.cs.

◆ VersionRoutingTag

string Csla.ApplicationContext.VersionRoutingTag
staticgetset

Gets a value representing the application version for use in server-side data portal routing.

Definition at line 173 of file ApplicationContext.cs.