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.
DataPortalContext.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="DataPortalContext.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Provides consistent context information between the client</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Security.Principal;
10using System.Collections.Specialized;
11using Csla.Core;
12
13namespace Csla.Server
14{
20 public class DataPortalContext : Csla.Serialization.Mobile.IMobileObject, IUseApplicationContext
21 {
22 private IPrincipal _principal;
23 private bool _remotePortal;
24 private string _clientCulture;
25 private string _clientUICulture;
26 private ContextDictionary _clientContext;
27 [NonSerialized]
28 private TransactionalTypes _transactionalType;
29 [NonSerialized]
30 private ObjectFactoryAttribute _factoryInfo;
31
36 public IPrincipal Principal
37 {
38 get { return _principal; }
39 }
40
46 public bool IsRemotePortal
47 {
48 get { return _remotePortal; }
49 }
50
55 public string ClientCulture
56 {
57 get { return _clientCulture; }
58 }
59
64 public string ClientUICulture
65 {
66 get { return _clientUICulture; }
67 }
68 internal ContextDictionary ClientContext
69 {
70 get { return _clientContext; }
71 }
72
79 {
80 get { return _transactionalType; }
81 internal set { _transactionalType = value; }
82 }
83
91 {
92 get { return _factoryInfo; }
93 internal set { _factoryInfo = value; }
94 }
95
96 private ApplicationContext ApplicationContext { get; set; }
98
105 public DataPortalContext(ApplicationContext applicationContext, IPrincipal principal, bool isRemotePortal)
106 {
107 ApplicationContext = applicationContext;
108 _principal = principal;
109 _remotePortal = isRemotePortal;
110 _clientCulture = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
111 _clientUICulture = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
112 _clientContext = applicationContext.ContextManager.GetClientContext(applicationContext.ExecutionLocation);
113 }
114
124 public DataPortalContext(ApplicationContext applicationContext, IPrincipal principal, bool isRemotePortal, string clientCulture, string clientUICulture, ContextDictionary clientContext)
125 {
126 ApplicationContext = applicationContext;
127 _principal = principal;
128 _clientContext = clientContext;
129 _clientCulture = clientCulture;
130 _clientUICulture = clientUICulture;
131 _remotePortal = isRemotePortal;
132 }
133
138 { }
139
140 void Serialization.Mobile.IMobileObject.GetState(Serialization.Mobile.SerializationInfo info)
141 {
142 info.AddValue("principal", Csla.Serialization.SerializationFormatterFactory.GetFormatter(ApplicationContext).Serialize(_principal));
143 info.AddValue("clientContext", Csla.Serialization.SerializationFormatterFactory.GetFormatter(ApplicationContext).Serialize(_clientContext));
144 info.AddValue("clientCulture", _clientCulture);
145 info.AddValue("clientUICulture", _clientUICulture);
146 info.AddValue("isRemotePortal", _remotePortal);
147 }
148
149 void Serialization.Mobile.IMobileObject.GetChildren(Serialization.Mobile.SerializationInfo info, Serialization.Mobile.MobileFormatter formatter)
150 {
151 }
152
153 void Serialization.Mobile.IMobileObject.SetState(Serialization.Mobile.SerializationInfo info)
154 {
155 _principal = (IPrincipal)Csla.Serialization.SerializationFormatterFactory.GetFormatter(ApplicationContext).Deserialize(info.GetValue<byte[]>("principal"));
156 _clientContext = (ContextDictionary)Csla.Serialization.SerializationFormatterFactory.GetFormatter(ApplicationContext).Deserialize(info.GetValue<byte[]>("clientContext"));
157 _clientCulture = info.GetValue<string>("clientCulture");
158 _clientUICulture = info.GetValue<string>("clientUICulture");
159 _remotePortal = info.GetValue<bool>("isRemotePortal");
160 }
161
162 void Serialization.Mobile.IMobileObject.SetChildren(Serialization.Mobile.SerializationInfo info, Serialization.Mobile.MobileFormatter formatter)
163 {
164 }
165 }
166}
Provides consistent context information between the client and server DataPortal objects.
ExecutionLocations ExecutionLocation
Returns a value indicating whether the application code is currently executing on the client or serve...
IContextManager ContextManager
Gets the context manager responsible for storing user and context information for the application.
Dictionary type that is serializable with the SerializationFormatterFactory.GetFormatter().
Provides consistent context information between the client and server DataPortal objects.
string ClientCulture
The culture setting on the client workstation.
bool IsRemotePortal
Returns true if the server-side DataPortal is running on a remote server via remoting.
DataPortalContext(ApplicationContext applicationContext, IPrincipal principal, bool isRemotePortal)
Creates a new DataPortalContext object.
string ClientUICulture
The culture setting on the client workstation.
IPrincipal Principal
The current principal object if CSLA security is being used.
ObjectFactoryAttribute FactoryInfo
Gets the current ObjectFactory attribute value (if any).
DataPortalContext()
Default constructor for use by SerializationFormatterFactory.GetFormatter().
DataPortalContext(ApplicationContext applicationContext, IPrincipal principal, bool isRemotePortal, string clientCulture, string clientUICulture, ContextDictionary clientContext)
Creates a new DataPortalContext object.
TransactionalTypes TransactionalType
Gets the current transactional type.
Specifies that the data portal should invoke a factory object rather than the business object.
ContextDictionary GetClientContext(ApplicationContext.ExecutionLocations executionLocation)
Gets the client context.
Implement if a class requires access to the CSLA ApplicationContext type.
ApplicationContext ApplicationContext
Gets or sets the current ApplicationContext object.
@ Serialization
The object is being serialized for a clone or data portal operation.
TransactionalTypes
Provides a list of possible transactional technologies to be used by the server-side DataPortal.
@ Serializable
Prevents updating or inserting until the transaction is complete.