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.
EditableGetSet.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="EditableGetSet.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>no summary</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Collections.Generic;
10using System.Text;
11using Csla;
15
17{
18#if TESTING
19 [System.Diagnostics.DebuggerNonUserCode]
20#endif
22 public class EditableGetSet : EditableGetSetBase<EditableGetSet>
23 {
24 private static Csla.PropertyInfo<string> FieldBackedStringProperty = RegisterProperty<string>(typeof(EditableGetSet), new Csla.PropertyInfo<string>("FieldBackedString", RelationshipTypes.PrivateField));
25 private string _fieldBackedString = FieldBackedStringProperty.DefaultValue;
26 public string FieldBackedString
27 {
28 get { return GetProperty<string>(FieldBackedStringProperty, _fieldBackedString); }
29 set { SetProperty<string>(FieldBackedStringProperty, ref _fieldBackedString, value); }
30 }
31
32 private static Csla.PropertyInfo<int> F02Property = RegisterProperty<int>(typeof(EditableGetSet), new Csla.PropertyInfo<int>("F02", RelationshipTypes.PrivateField));
33 private int _f02 = F02Property.DefaultValue;
34 public int F02
35 {
36 get { return GetProperty<int>(F02Property, _f02); }
37 set { SetProperty<int>(F02Property, ref _f02, value); }
38 }
39
40 private static Csla.PropertyInfo<string> F03Property = RegisterProperty<string>(c => c.F03, "field 3", "n/a", RelationshipTypes.PrivateField);
41 private string _f03 = F03Property.DefaultValue;
42 public string F03
43 {
44 get { return GetProperty<string>(F03Property, _f03); }
45 set { SetProperty<string>(F03Property, ref _f03, value); }
46 }
47
48 private static Csla.PropertyInfo<Csla.SmartDate> F04Property = RegisterProperty<Csla.SmartDate>(typeof(EditableGetSet), new Csla.PropertyInfo<Csla.SmartDate>("F04", RelationshipTypes.PrivateField));
49 private Csla.SmartDate _F04 = F04Property.DefaultValue;
50 public string F04
51 {
52 get { return GetPropertyConvert<Csla.SmartDate, string>(F04Property, _F04); }
53 set { SetPropertyConvert(F04Property, ref _F04, value); }
54 }
55
56 private static Csla.PropertyInfo<bool> F05Property = RegisterProperty<bool>(nameof(F05), "field 5", false, RelationshipTypes.PrivateField);
57 private bool _f05 = F05Property.DefaultValue;
58 public bool F05
59 {
60 get { return GetProperty<bool>(F05Property, _f05); }
61 set { SetProperty<bool>(F05Property, ref _f05, value); }
62 }
63
64 private static Csla.PropertyInfo<object> F06Property = RegisterProperty<object>(c => c.F06, "field 6", null, RelationshipTypes.PrivateField);
65 private object _F06 = string.Empty;
66 public string F06
67 {
68 get { return GetPropertyConvert<object, string>(F06Property, _F06); }
69 set { SetPropertyConvert<object, string>(F06Property, ref _F06, value); }
70 }
71
72 public static readonly PropertyInfo<string> ManagedStringFieldProperty = RegisterProperty<string>(nameof(ManagedStringField));
73 public string ManagedStringField
74 {
75 get => GetProperty(ManagedStringFieldProperty);
76 set => SetProperty(ManagedStringFieldProperty, value);
77 }
78
80 {
81 get { return FieldManager.IsFieldDirty(ManagedStringFieldProperty); }
82 }
83
84 private static Csla.PropertyInfo<int> M02Property = RegisterProperty(typeof(EditableGetSet), new Csla.PropertyInfo<int>("M02"));
85 public int M02
86 {
87 get { return GetProperty<int>(M02Property); }
88 set { SetProperty<int>(M02Property, value); }
89 }
90
91 public void LoadM02(int value)
92 {
93 var p = M02Property as Core.IPropertyInfo;
94 LoadProperty(p, value);
95 }
96
97 private static Csla.PropertyInfo<string> M03Property = RegisterProperty(c => c.M03, "field 3", "n/a");
98 public string M03
99 {
100 get { return GetProperty<string>(M03Property); }
101 set { SetProperty<string>(M03Property, value); }
102 }
103
104 private static Csla.PropertyInfo<Csla.SmartDate> M04Property = RegisterProperty(typeof(EditableGetSet), new Csla.PropertyInfo<Csla.SmartDate>("M04"));
105 public string M04
106 {
107 get { return GetPropertyConvert<Csla.SmartDate, string>(M04Property); }
108 set { SetPropertyConvert(M04Property, value); }
109 }
110
111 private static Csla.PropertyInfo<bool> M05Property = RegisterProperty<bool>(c => c.M05, "field 5");
112 public bool M05
113 {
114 get { return GetProperty(M05Property); }
115 set { SetProperty(M05Property, value); }
116 }
117
118 private static Csla.PropertyInfo<Guid> M06Property = RegisterProperty<Guid>(c => c.M06, "field 6");
119 public Guid M06
120 {
121 get { return GetProperty(M06Property); }
122 set { SetProperty(M06Property, value); }
123 }
124
125 private static Csla.PropertyInfo<object> M07Property = RegisterProperty<object>(c => c.M07, "field 7");
126 public string M07
127 {
128 get { return GetPropertyConvert<object, string>(M07Property); }
129 set { SetPropertyConvert<object, string>(M07Property, value); }
130 }
131
132 public static readonly PropertyInfo<string> _m08Property = RegisterProperty<string>(c => c.M08);
133 internal string M08
134 {
135 get { return GetProperty(_m08Property); }
136 set { SetProperty(_m08Property, value); }
137 }
138
139 public static readonly PropertyInfo<string> _m09Property = RegisterProperty<string>(c => c.M09);
140 private string M09
141 {
142 get { return GetProperty(_m09Property); }
143 set { SetProperty(_m09Property, value); }
144 }
145
146 public void LoadInternalAndPrivate(string value)
147 {
148 using (BypassPropertyChecks)
149 {
150 LoadProperty(_m08Property, value);
151 LoadProperty(_m09Property, value);
152 }
153 }
154
155 private static Csla.PropertyInfo<EditableGetSet> ManagedChildProperty = RegisterProperty(
156 typeof(EditableGetSet), new Csla.PropertyInfo<EditableGetSet>("ManagedChild", RelationshipTypes.LazyLoad));
158 {
159 get
160 {
161 return LazyGetProperty(ManagedChildProperty, () => GetDataPortal<EditableGetSet>().Create());
162 }
163 }
164
165 private static Csla.PropertyInfo<ChildList> ManagedChildListProperty = RegisterProperty(
166 typeof(EditableGetSet), new Csla.PropertyInfo<ChildList>("ManagedChildList", RelationshipTypes.LazyLoad));
168 {
169 get
170 {
171 return LazyGetProperty(ManagedChildListProperty, () => GetDataPortal<ChildList>().Create());
172 }
173 }
174
175 private static PropertyInfo<ChildList> LazyChildProperty =
176 RegisterProperty(new PropertyInfo<ChildList>("LazyChild", "Child list", null, RelationshipTypes.LazyLoad));
178 {
179 get { return LazyGetProperty(LazyChildProperty, () => GetDataPortal<ChildList>().Create()); }
180 set { SetProperty(LazyChildProperty, value); }
181 }
182
183 public new int EditLevel
184 {
185 get { return base.EditLevel; }
186 }
187
188 public new void MarkClean()
189 {
190 base.MarkClean();
191 }
192
194 {
195 }
196
197 #region Factory Methods
198
200 {
201 return dataPortal.Create();
202 }
203
205 {
206 return childDataPortal.CreateChild();
207 }
208
210 {
211 return dataPortal.Fetch();
212 }
213
215 {
216 return dataPortal.FetchChild();
217 }
218
219 #endregion
220
221 #region Data Access
222
223 [Create]
224 private void Create([Inject] IChildDataPortal<EditableGetSet> dataPortal)
225 {
226 LoadProperty(M06Property, null);
227 }
228
229 [CreateChild]
230 private void CreateChild()
231 {
232 LoadProperty(M06Property, null);
233 }
234
235 [Fetch]
236 private void DataPortal_Fetch()
237 {
238 LoadProperty(M06Property, null);
239 }
240
241 [FetchChild]
242 private void DataPortal_FetchChild()
243 {
244 LoadProperty(M06Property, null);
245 }
246
247 [Insert]
248 [InsertChild]
249 protected void DataPortal_Insert()
250 {
251 FieldManager.UpdateChildren();
252 }
253
254 [Update]
255 [UpdateChild]
256 protected void DataPortal_Update()
257 {
258 FieldManager.UpdateChildren();
259 }
260
261 #endregion
262
263 #region MobileObject
264
265 protected override void OnGetState(SerializationInfo info, Csla.Core.StateMode mode)
266 {
267 if(_fieldBackedString!=null)
268 info.AddValue("_fieldBackedString", _fieldBackedString);
269 if (_f02 != 0)
270 info.AddValue("_f02", _f02);
271 if (_f03 != null)
272 info.AddValue("_f03", _f03);
273 if (_F04 != default(Csla.SmartDate))
274 info.AddValue("_f04", _F04);
275 if (_f05 == true)
276 info.AddValue("_f05", _f05);
277
278 base.OnGetState(info, mode);
279 }
280
281 protected override void OnSetState(SerializationInfo info, Csla.Core.StateMode mode)
282 {
283 if (info.Values.ContainsKey("_fieldBackedString"))
284 _fieldBackedString = info.GetValue<string>("_fieldBackedString");
285 if (info.Values.ContainsKey("_f02"))
286 _f02 = info.GetValue<int>("_f02");
287 if(info.Values.ContainsKey("_f03"))
288 _f03 = info.GetValue<string>("_f03");
289 if(info.Values.ContainsKey("_f04"))
290 _F04 = info.GetValue<Csla.SmartDate>("_f04");
291 if (info.Values.ContainsKey("_f05"))
292 _f05 = info.GetValue<bool>("_f05");
293
294 base.OnSetState(info, mode);
295 }
296
297 #endregion
298
299 #region Private Helper Methods
300
306 private IDataPortal<T> GetDataPortal<T>() where T:class
307 {
309 }
310
311 #endregion
312 }
313
315 public class EditableGetSetNFI : EditableGetSetNFIBase<EditableGetSetNFI>
316 {
317 public static PropertyInfo<string> DataProperty = RegisterProperty(new PropertyInfo<string>("Data", "Data"));
318 public string Data
319 {
320 get { return GetProperty(DataProperty); }
321 set { SetProperty(DataProperty, value); }
322 }
323
324 public new int EditLevel
325 {
326 get { return base.EditLevel; }
327 }
328
329 public new void MarkClean()
330 {
331 base.MarkClean();
332 }
333
335 {
336 MarkNew();
337 MarkClean();
338 }
339
340 public EditableGetSetNFI(bool isChild)
341 {
342 if (isChild)
343 {
344 MarkAsChild();
345 MarkNew();
346 }
347 }
348
349 #region Factory Methods
350
352 {
353 return dataPortal.Fetch();
354 }
355
356 #endregion
357
358 #region Data Access
359
360 private void DataPortal_Fetch()
361 {
362 LoadProperty(DataProperty, "Hi");
363 }
364
365 [Insert]
366 protected void DataPortal_Insert()
367 {
368 }
369
370 [Update]
371 protected void DataPortal_Update()
372 {
373 //FieldManager.UpdateChildren();
374 }
375
376
377 internal void Insert()
378 {
379 MarkOld();
380 }
381
382 internal void Update()
383 {
384 MarkOld();
385 }
386
387 #endregion
388 }
389}
Provides consistent context information between the client and server DataPortal objects.
object GetRequiredService(Type serviceType)
Attempts to get service via DI using ServiceProviderServiceExtensions.GetRequiredService.
Maintains metadata about a property.
Object containing the serialization data for a specific object.
Dictionary< string, FieldData > Values
Dictionary containg field data.
void AddValue(string name, object value)
Adds a value to the serialization stream.
static EditableGetSet GetObject(IDataPortal< EditableGetSet > dataPortal)
static EditableGetSet GetChildObject(IChildDataPortal< EditableGetSet > dataPortal)
static EditableGetSet NewObject(IDataPortal< EditableGetSet > dataPortal)
static readonly PropertyInfo< string > _m08Property
static readonly PropertyInfo< string > ManagedStringFieldProperty
static EditableGetSet NewChildObject(IChildDataPortal< EditableGetSet > childDataPortal)
static readonly PropertyInfo< string > _m09Property
override void OnGetState(SerializationInfo info, Csla.Core.StateMode mode)
override void OnSetState(SerializationInfo info, Csla.Core.StateMode mode)
static PropertyInfo< string > DataProperty
static EditableGetSetNFI GetObject(IDataPortal< EditableGetSetNFI > dataPortal)
Interface defining the members of the child data portal type.
object CreateChild(params object[] criteria)
Called by a factory method in a business class to create a new object, which is loaded with default v...
object FetchChild(params object[] criteria)
Called by a factory method in a business class to retrieve an object, which is loaded with values fro...
Interface defining the members of the data portal type.
Definition: IDataPortalT.cs:17
object Fetch(params object[] criteria)
Called by a factory method in a business class to retrieve an object, which is loaded with values fro...
object Create(params object[] criteria)
Called by a factory method in a business class to create a new object, which is loaded with default v...
@ Guid
Globally unique identifier / Guid
RelationshipTypes
List of valid relationship types between a parent object and another object through a managed propert...
@ Serializable
Prevents updating or inserting until the transaction is complete.
@ Update
Update operation (includes insert, update and delete self).
@ Fetch
Fetch operation.
Provides a date data type that understands the concept of an empty date value.
Definition: SmartDate.cs:32