9using System.Collections.Generic;
12using System.Threading.Tasks;
13using System.Runtime.InteropServices.WindowsRuntime;
14using Windows.Foundation;
32 public IAsyncOperation<IList<byte>>
Create(
string objectTypeName, [ReadOnlyArray]
byte[] criteriaData, [ReadOnlyArray]
byte[] contextData)
34 return Task<IList<byte>>.Run(async () =>
36 var portal = GetPortal();
37 var method = portal.GetType().GetMethod(
"Create");
38 var result = await (Task<
byte[]>)method.Invoke(portal,
new object[] { objectTypeName, criteriaData, contextData });
39 return (IList<byte>)result;
40 }).AsAsyncOperation();
51 public IAsyncOperation<IList<byte>>
Fetch(
string objectTypeName, [ReadOnlyArray]
byte[] criteriaData, [ReadOnlyArray]
byte[] contextData)
53 return Task<IList<byte>>.Run(async () =>
55 var portal = GetPortal();
56 var method = portal.GetType().GetMethod(
"Fetch");
57 var result = await (Task<
byte[]>)method.Invoke(portal,
new object[] { objectTypeName, criteriaData, contextData });
58 return (IList<byte>)result;
59 }).AsAsyncOperation();
69 public IAsyncOperation<IList<byte>>
Update([ReadOnlyArray]
byte[] objectData, [ReadOnlyArray]
byte[] contextData)
71 return Task<IList<byte>>.Run(async () =>
73 var portal = GetPortal();
74 var method = portal.GetType().GetMethod(
"Update");
75 var result = await (Task<
byte[]>)method.Invoke(portal,
new object[] { objectData, contextData });
76 return (IList<byte>)result;
77 }).AsAsyncOperation();
88 public IAsyncOperation<IList<byte>>
Delete(
string objectTypeName, [ReadOnlyArray]
byte[] criteriaData, [ReadOnlyArray]
byte[] contextData)
90 return Task<IList<byte>>.Run(async () =>
92 var portal = GetPortal();
93 var method = portal.GetType().GetMethod(
"Delete");
94 var result = await (Task<
byte[]>)method.Invoke(portal,
new object[] { objectTypeName, criteriaData, contextData });
95 return (IList<byte>)result;
96 }).AsAsyncOperation();
99 private object GetPortal()
101 var typeName =
"Csla.Server.Hosts.BrokeredPortal, Csla.BrokeredDataPortal";
105 type = Type.GetType(typeName);
107 throw new TypeLoadException(
"BrokeredHost: " + typeName);
111 throw new TypeLoadException(
"BrokeredHost: " + typeName, ex);
113 return Activator.CreateInstance(type);
Brokered assembly entry point for the data portal.
IAsyncOperation< IList< byte > > Fetch(string objectTypeName, [ReadOnlyArray] byte[] criteriaData, [ReadOnlyArray] byte[] contextData)
Get an existing business object.
IAsyncOperation< IList< byte > > Update([ReadOnlyArray] byte[] objectData, [ReadOnlyArray] byte[] contextData)
Update a business object.
IAsyncOperation< IList< byte > > Delete(string objectTypeName, [ReadOnlyArray] byte[] criteriaData, [ReadOnlyArray] byte[] contextData)
Delete a business object.
IAsyncOperation< IList< byte > > Create(string objectTypeName, [ReadOnlyArray] byte[] criteriaData, [ReadOnlyArray] byte[] contextData)
Create and initialize a business object.