9using System.Threading.Tasks;
30 Activator = activator;
31 ExceptionInspector = exceptionInspector;
35 private IDataPortalActivator Activator {
get;
set; }
36 private IDataPortalExceptionInspector ExceptionInspector {
get;
set; }
47 [System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Globalization",
"CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId =
"Csla.Server.DataPortalException.#ctor(System.String,System.Exception,Csla.Server.DataPortalResult)")]
48 [System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Design",
"CA1031:DoNotCatchGeneralExceptionTypes")]
49 public async Task<DataPortalResult>
Create(
52 DataPortalTarget obj =
null;
58 obj.OnDataPortalInvoke(eventArgs);
60 await obj.CreateAsync(criteria, isSync);
62 obj.OnDataPortalInvokeComplete(eventArgs);
70 obj.OnDataPortalException(eventArgs, ex);
77 if (obj !=
null) outval = obj.Instance;
85 object reference =
null;
87 reference = obj.Instance;
101 [System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Globalization",
"CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId =
"Csla.Server.DataPortalException.#ctor(System.String,System.Exception,Csla.Server.DataPortalResult)")]
102 [System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Design",
"CA1031:DoNotCatchGeneralExceptionTypes")]
105 DataPortalTarget obj =
null;
111 obj.OnDataPortalInvoke(eventArgs);
113 await obj.FetchAsync(criteria, isSync);
115 obj.OnDataPortalInvokeComplete(eventArgs);
123 obj.OnDataPortalException(eventArgs, ex);
129 object outval =
null;
130 if (obj !=
null) outval = obj.Instance;
138 object reference =
null;
140 reference = obj.Instance;
153 [System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Performance",
"CA1800:DoNotCastUnnecessarily")]
154 [System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Globalization",
"CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId =
"Csla.Server.DataPortalException.#ctor(System.String,System.Exception,Csla.Server.DataPortalResult)")]
158 Type objectType = obj.GetType();
160 if (lb.Instance is Core.ICommandObject)
161 return await Execute(lb, context, isSync);
167 lb.OnDataPortalInvoke(eventArgs);
168 await lb.UpdateAsync(isSync);
170 lb.OnDataPortalInvokeComplete(eventArgs);
177 lb.OnDataPortalException(eventArgs, ex);
190 object reference =
null;
192 reference = lb.Instance;
197 private async Task<DataPortalResult> Execute(DataPortalTarget obj,
DataPortalContext context,
bool isSync)
200 Type objectType = obj.Instance.GetType();
205 obj.OnDataPortalInvoke(eventArgs);
206 await obj.ExecuteAsync(isSync);
208 obj.OnDataPortalInvokeComplete(eventArgs);
215 obj.OnDataPortalException(eventArgs, ex);
221 object reference =
null;
222 reference = obj.Instance ?? obj;
223 throw DataPortal.NewDataPortalException(
225 new DataPortalExceptionHandler(ExceptionInspector).InspectException(reference.GetType(), reference,
null,
"DataPortal.Execute", ex),
230 object reference =
null;
232 reference = obj.Instance;
245 [System.Diagnostics.CodeAnalysis.SuppressMessage(
"Microsoft.Globalization",
"CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId =
"Csla.Server.DataPortalException.#ctor(System.String,System.Exception,Csla.Server.DataPortalResult)")]
248 DataPortalTarget obj =
null;
254 obj.OnDataPortalInvoke(eventArgs);
255 await obj.DeleteAsync(criteria, isSync);
257 obj.OnDataPortalInvokeComplete(eventArgs);
264 obj.OnDataPortalException(eventArgs, ex);
277 object reference =
null;
279 reference = obj.Instance;
Provides consistent context information between the client and server DataPortal objects.
object CreateInstanceDI(Type objectType, params object[] parameters)
Creates an object using 'Activator.CreateInstance' using service provider (if one is available) to po...
object CreateInstance(Type objectType, params object[] parameters)
Creates an object using Activator.
Provides information about the DataPortal call.
A strongly-typed resource class, for looking up localized strings, etc.
static string FailedOnServer
Looks up a localized string similar to failed on the server.
Provides consistent context information between the client and server DataPortal objects.
This class provides a hook for developers to add custom error handling in the DataPortal.
Exception InspectException(Type objectType, object criteria, string methodName, Exception ex)
Transforms the exception in a Fetch, Create or Execute method.
Implements the server-side DataPortal message router as discussed in Chapter 4.
Returns data from the server-side DataPortal to the client-side DataPortal.
Implements the server-side DataPortal as discussed in Chapter 4.
async Task< DataPortalResult > Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
Get an existing business object.
async Task< DataPortalResult > Create(Type objectType, object criteria, DataPortalContext context, bool isSync)
Create a new business object.
SimpleDataPortal(ApplicationContext applicationContext, IDataPortalActivator activator, IDataPortalExceptionInspector exceptionInspector)
Creates an instance of the type
async Task< DataPortalResult > Update(object obj, DataPortalContext context, bool isSync)
Update a business object.
async Task< DataPortalResult > Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
Delete a business object.
Defines a type used to activate concrete business instances.
void InitializeInstance(object obj)
Initializes an existing business object instance.
void FinalizeInstance(object obj)
Finalizes an existing business object instance.
Implement this interface to check a DataPortalException before returning Exception to the client.
Interface implemented by server-side data portal components.
DataPortalOperations
List of data portal operations.