9using System.Collections.Generic;
12using System.Threading.Tasks;
29 const int customerIDThrowsException = 99;
31 private Customer() { }
33 internal static Customer NewCustomer()
35 var returnValue =
new Customer();
36 returnValue.Name =
"New";
37 returnValue.MarkAsChild();
41 private static PropertyInfo<int> IdProperty = RegisterProperty<int>(c=>c.Id,
"Customer Id", 0);
46 return GetProperty<int>(IdProperty);
50 SetProperty<int>(IdProperty, value);
54 private static PropertyInfo<string> NameProperty = RegisterProperty<string>(c=>c.Name,
"Customer Name",
"");
59 return GetProperty<string>(NameProperty);
63 SetProperty<string>(NameProperty, value);
67 private static PropertyInfo<string> MethodProperty = RegisterProperty<string>(c=>c.Method,
"Method",
"");
72 return GetProperty<string>(MethodProperty);
76 SetProperty<string>(MethodProperty, value);
81 private static PropertyInfo<SmartDate> DateCreatedProperty = RegisterProperty<SmartDate>(c=>c.DateCreated,
"Date Created On");
86 return GetProperty<SmartDate>(DateCreatedProperty).Text;
93 SetProperty<SmartDate>(DateCreatedProperty, test);
99 private static PropertyInfo<bool> ThrowExceptionProperty = RegisterProperty<bool>(c=>c.ThrowException,
"ThrowException",
false);
104 return GetProperty<bool>(ThrowExceptionProperty);
108 LoadProperty<bool>(ThrowExceptionProperty, value);
112 private static PropertyInfo<DateTimeOffset> DateTimeOffsetNullProperty = RegisterProperty<DateTimeOffset>(c=>c.DateTimeOffsetNull,
"DateTimeOffsetNull");
117 return GetProperty(DateTimeOffsetNullProperty);
121 LoadProperty(DateTimeOffsetNullProperty, value);
130 return GetProperty(DateTimeOffsetNotNullProperty);
134 LoadProperty(DateTimeOffsetNotNullProperty, value);
138 private static PropertyInfo<DateTimeOffset?> DateTimeOffsetNullableProperty = RegisterProperty<DateTimeOffset?>(c=>c.DateTimeOffsetNullable,
"DateTimeOffsetNullable");
143 return GetProperty(DateTimeOffsetNullableProperty);
147 LoadProperty(DateTimeOffsetNullableProperty, value);
156 return GetProperty(TypeProperty);
160 SetProperty(TypeProperty, value);
170 return GetProperty<CustomerContactList>(ContactsProperty);
181 public class FetchCriteria :
CriteriaBase<FetchCriteria>
188 _customerId = customerID;
191 private int _customerId;
203 base.OnGetState(info, mode);
204 info.AddValue(
"_customerId", _customerId);
208 base.OnSetState(info, mode);
209 _customerId = info.GetValue<
int>(
"_customerId");
214 internal static Customer GetCustomer(
int customerID)
217 newCustomer.DataPortal_Fetch(customerID);
218 newCustomer.MarkAsChild();
219 newCustomer.MarkOld();
225 LoadProperty(IdProperty, criteria);
226 LoadProperty(NameProperty,
"Customer Name for Id: " + criteria.ToString());
227 LoadProperty(DateCreatedProperty,
new SmartDate(
new DateTime(2000 + criteria, 1, 1)));
229 LoadProperty(DateTimeOffsetNotNullProperty, DateTimeOffset.Now);
232 if (criteria == customerIDThrowsException)
233 throw new ApplicationException(
"Test for Silverlight DataSource Error!");
238 LoadProperty(IdProperty, criteria);
239 LoadProperty(NameProperty,
"New Customer for Id: " + criteria.ToString());
240 LoadProperty(DateCreatedProperty,
new SmartDate(DateTime.Today));
241 LoadProperty(DateTimeOffsetNotNullProperty, DateTimeOffset.Now);
248 Method =
"Deleted Customer " + GetProperty<string>(NameProperty);
254 Method =
"Deleted Customer ID " + criteria.ToString();
260 Method =
"Inserted Customer " + GetProperty<string>(NameProperty);
267 Method =
"Updating Customer " + GetProperty<string>(NameProperty);
274 public class CustomerWO_DP_XYZ :
BusinessBase<CustomerWO_DP_XYZ>
277 private async Task Create()
This is the base class from which most business objects will be derived.
Base type from which Criteria classes can be derived in a business class.
Client side data portal used for making asynchronous data portal calls in .NET.
void UpdateChild(T child)
Inserts, updates or deletes an existing child business object.
Maintains metadata about a property.
Business rule for a minimum value.
Object containing the serialization data for a specific object.
FetchCriteria(int customerID)
override void OnGetState(Csla.Serialization.Mobile.SerializationInfo info, StateMode mode)
override void OnSetState(Csla.Serialization.Mobile.SerializationInfo info, StateMode mode)
void DataPortal_Fetch(int criteria)
void DataPortal_Create(int criteria)
void DataPortal_DeleteSelf()
CustomerContactList Contacts
DateTimeOffset DateTimeOffsetNull
DateTimeOffset? DateTimeOffsetNullable
DateTimeOffset DateTimeOffsetNotNull
override void AddBusinessRules()
void DataPortal_Delete(int criteria)
Task CheckRulesAsync()
Invokes all rules for the business type.
StateMode
Indicates the reason the MobileFormatter functionality has been invoked.
@ DateTimeOffset
Date/time plus time zone / DateTimeOffset
@ Serializable
Prevents updating or inserting until the transaction is complete.
@ Update
Update operation (includes insert, update and delete self).
@ Delete
Delete operation.
Provides a date data type that understands the concept of an empty date value.
static bool TryParse(string value, ref SmartDate result)
Converts a string value into a SmartDate.