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.
DataPortalBroker.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="DataPortalBroker.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Allows interception of DataPortal call</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Threading.Tasks;
10
11namespace Csla.Server
12{
18 {
23 public DataPortalBroker(DataPortalSelector dataPortalSelector)
24 {
25 DataPortalSelector = dataPortalSelector;
26 }
27
28 private DataPortalSelector DataPortalSelector { get; set; }
33 public static IDataPortalServer DataPortalServer { get; set; }
34
44 public Task<DataPortalResult> Create(Type objectType, object criteria, DataPortalContext context, bool isSync)
45 {
46 if (DataPortalServer != null)
47 {
48 return DataPortalServer.Create(objectType, criteria, context, isSync);
49 }
50 else
51 {
52 return DataPortalSelector.Create(objectType, criteria, context, isSync);
53 }
54 }
55
65 public Task<DataPortalResult> Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
66 {
67 if (DataPortalServer != null)
68 {
69 return DataPortalServer.Fetch(objectType, criteria, context, isSync);
70 }
71 else
72 {
73 return DataPortalSelector.Fetch(objectType, criteria, context, isSync);
74 }
75 }
76
85 public Task<DataPortalResult> Update(object obj, DataPortalContext context, bool isSync)
86 {
87 if (DataPortalServer != null)
88 {
89 return DataPortalServer.Update(obj, context, isSync);
90 }
91 else
92 {
93 return DataPortalSelector.Update(obj, context, isSync);
94 }
95 }
96
106 public Task<DataPortalResult> Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
107 {
108 if (DataPortalServer != null)
109 {
110 return DataPortalServer.Delete(objectType, criteria, context, isSync);
111 }
112 else
113 {
114 return DataPortalSelector.Delete(objectType, criteria, context, isSync);
115 }
116 }
117 }
118}
Allows the Data Portal call to be intercepted by a custom IDataPortalServer implementation.
Task< DataPortalResult > Update(object obj, DataPortalContext context, bool isSync)
Update a business object.
Task< DataPortalResult > Create(Type objectType, object criteria, DataPortalContext context, bool isSync)
Create a new business object.
static IDataPortalServer DataPortalServer
Gets or sets a reference to a implementation of IDataPortalServer to be used.
DataPortalBroker(DataPortalSelector dataPortalSelector)
Task< DataPortalResult > Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
Get an existing business object.
Task< DataPortalResult > Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
Delete a business object.
Provides consistent context information between the client and server DataPortal objects.
Selects the appropriate data portal implementation to invoke based on the object and configuration.
async Task< DataPortalResult > Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
Get an existing business object.
async Task< DataPortalResult > Update(object obj, DataPortalContext context, bool isSync)
Update a business object.
async Task< DataPortalResult > Create(Type objectType, object criteria, DataPortalContext context, bool isSync)
Create a new business object.
async Task< DataPortalResult > Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
Delete a business object.
Interface implemented by server-side data portal components.
Task< DataPortalResult > Update(object obj, DataPortalContext context, bool isSync)
Update a business object.
Task< DataPortalResult > Create(Type objectType, object criteria, DataPortalContext context, bool isSync)
Create a new business object.
Task< DataPortalResult > Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
Get an existing business object.
Task< DataPortalResult > Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
Delete a business object.