10using System.Threading.Tasks;
31 FactoryLoader = factoryLoader;
32 ExceptionInspector = inspector;
36 private IObjectFactoryLoader FactoryLoader {
get;
set; }
37 private IDataPortalExceptionInspector ExceptionInspector {
get;
set; }
39 #region Method invokes
43 object factory = FactoryLoader.
GetFactory(factoryTypeName);
44 var eventArgs =
new DataPortalEventArgs(context, objectType,
null, operation);
50 Utilities.ThrowIfAsyncMethodOnSyncClient(ApplicationContext, isSync, factory, methodName);
53 if (result is Exception error)
57 throw new InvalidOperationException(
string.Format(
"{0}.IsBusy == true", objectType.Name));
64 factory,
"InvokeError",
new DataPortalEventArgs(context, objectType,
null, operation, ex));
67 return new DataPortalResult(ApplicationContext, result);
70 private async Task<DataPortalResult> InvokeMethod(
string factoryTypeName,
DataPortalOperations operation,
string methodName, Type objectType,
object e,
DataPortalContext context,
bool isSync)
72 object factory = FactoryLoader.
GetFactory(factoryTypeName);
73 var eventArgs =
new DataPortalEventArgs(context, objectType, e, operation);
79 Utilities.ThrowIfAsyncMethodOnSyncClient(ApplicationContext, isSync, factory, methodName, e);
82 if (result is Exception error)
86 throw new InvalidOperationException(
string.Format(
"{0}.IsBusy == true", objectType.Name));
92 Csla.
Reflection.
MethodCaller.CallMethodIfImplemented(factory,
"InvokeError",
new DataPortalEventArgs(context, objectType, e, operation, ex));
95 return new DataPortalResult(ApplicationContext, result);
100 #region IDataPortalServer Members
170 string methodName =
string.Empty;
174 if (obj is Core.ICommandObject)
Csla.Server.DataPortalContext DataPortalContext
Provides consistent context information between the client and server DataPortal objects.
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.
ObjectFactoryAttribute FactoryInfo
Gets the current ObjectFactory attribute value (if any).
This class provides a hook for developers to add custom error handling in the DataPortal.
Implements the server-side DataPortal message router as discussed in Chapter 4.
Returns data from the server-side DataPortal to the client-side DataPortal.
Empty criteria used by the data portal as a placeholder for a create/fetch request that has no criter...
Server-side data portal implementation that invokes an object factory rather than directly interactin...
async Task< DataPortalResult > Update(object obj, DataPortalContext context, bool isSync)
Update a business object.
async Task< DataPortalResult > Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
Get an existing business object.
async Task< DataPortalResult > Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
Delete a business object.
FactoryDataPortal(ApplicationContext applicationContext, IObjectFactoryLoader factoryLoader, IDataPortalExceptionInspector inspector)
Creates an instance of the type.
async Task< DataPortalResult > Create(Type objectType, object criteria, DataPortalContext context, bool isSync)
Create a new business object.
string FetchMethodName
Name of the method to call for a fetch operation.
string DeleteMethodName
Name of the method to call for a delete operation.
string ExecuteMethodName
Name of the method to call for a Execute operation.
string UpdateMethodName
Name of the method to call for a update operation.
string CreateMethodName
Name of the method to call for a create operation.
string FactoryTypeName
Assembly qualified type name of the factory object.
bool IsBusy
Gets a value indicating whether the object, or any of the object's child objects, are busy running an...
Defines the common properties required objects that track their own status.
Implement this interface to check a DataPortalException before returning Exception to the client.
Interface implemented by server-side data portal components.
Defines an interface to be implemented by a factory loader object that returns ObjectFactory objects ...
object GetFactory(string factoryName)
Returns an ObjectFactory object.
DataPortalOperations
List of data portal operations.