9using System.Collections;
10using System.Collections.Generic;
26 : base(applicationContext) { }
35 if (target is IManageProperties imp)
37 FieldManager.FieldDataManager targetFieldManager =
null;
38 if (target is IUseFieldManager iufm)
39 targetFieldManager = iufm.FieldManager;
40 FieldManager.FieldDataManager sourceFieldManager =
null;
41 if (source is IUseFieldManager iufms)
42 sourceFieldManager = iufms.FieldManager;
44 var targetProperties = imp.GetManagedProperties();
45 foreach (var item
in targetProperties)
47 var sourceFieldExists =
true;
49 sourceFieldExists = sourceFieldManager.FieldExists(item);
50 object sourceValue =
null;
51 if (sourceFieldExists)
55 var targetFieldExists =
true;
57 targetFieldExists = targetFieldManager.FieldExists(item);
74 var targetFieldExists =
true;
76 targetFieldExists = targetFieldManager.FieldExists(item);
108 CopyField(source, target,
"_isDirty");
109 CopyField(source, target,
"_isNew");
110 CopyField(source, target,
"_isDeleted");
116 private static void CopyField(
object source,
object target,
string fieldName)
118 if (source ==
null)
return;
119 if (target ==
null)
return;
120 var sourceField = source.GetType().GetField(fieldName, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic);
121 if (sourceField !=
null)
123 var targetField = target.GetType().GetField(fieldName, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic);
124 if (targetField !=
null)
126 targetField.SetValue(target, sourceField.GetValue(source));
136 private void MergeGraph(IEditableCollection target, IEditableCollection source)
139 var listType = target.GetType();
140 var childType = Utilities.GetChildItemType(listType);
141 var genericTypeParams =
new Type[] { listType, childType };
142 var parameterTypes =
new Type[] { listType, listType };
143 System.Reflection.MethodInfo methodReference;
144 if (typeof(IExtendedBindingList).IsAssignableFrom(listType))
145 methodReference = this.GetType().GetMethod(
"MergeBusinessBindingListGraph");
147 methodReference = this.GetType().GetMethod(
"MergeBusinessListGraph");
148 var gr = methodReference.MakeGenericMethod(genericTypeParams);
149 gr.Invoke(
this,
new object[] { target, source });
160 where C : Core.IEditableBusinessObject
162 var deleted =
new List<C>();
163 foreach (var item
in target)
165 var sourceItem = source.Where(_ => _.Identity == item.Identity).FirstOrDefault();
166 if (sourceItem !=
null)
173 foreach (var item
in source)
174 if (target.Count(_ => _.Identity == item.Identity) == 0)
178 foreach (var item
in deleted)
190 where C : Core.IEditableBusinessObject
192 var deleted =
new List<C>();
193 foreach (var item
in target)
195 var sourceItem = source.Where(_ => _.Identity == item.Identity).FirstOrDefault();
196 if (sourceItem !=
null)
203 foreach (var item
in source)
204 if (target.Count(_ => _.Identity == item.Identity) == 0)
208 foreach (var item
in deleted)
Provides consistent context information between the client and server DataPortal objects.
This is the base class from which most business collections or lists will be derived.
This is the base class from which most business collections or lists will be derived.
Implements behavior to merge one object graph into a clone of itself (typically post-serialization).
GraphMerger(ApplicationContext applicationContext)
Creates an instance of the type.
void MergeGraph(IEditableBusinessObject target, IEditableBusinessObject source)
Merges state from source graph into target graph.
void MergeBusinessListGraph< T, C >(T target, T source)
Merges state from source graph into target graph.
void MergeBusinessBindingListGraph< T, C >(T target, T source)
Merges state from source graph into target graph.
void MarkOld(object obj)
Calls the MarkOld method on the specified object, if possible.
void MarkNew(object obj)
Calls the MarkNew method on the specified object, if possible.
void LoadProperty(object obj, IPropertyInfo propertyInfo, object newValue)
Loads a property's managed field with the supplied value.
Csla.Core.MobileList< C > GetDeletedList< C >(object obj)
Gets the list of deleted items from an editable collection.
void CheckRules(object obj)
Calls the ValidationRules.CheckRules() method on the specified object, if possible.
object ReadProperty(object obj, IPropertyInfo propertyInfo)
Reads a property's managed field value.
Defines the common methods required by all editable CSLA single objects.
Defines the common methods required by all editable CSLA collection objects.
bool IsNew
Returns true if this is a new object, false if it is a pre-existing object.
bool IsDirty
Returns true if this object's data, or any of its fields or child objects data, has been changed.
RelationshipTypes
List of valid relationship types between a parent object and another object through a managed propert...