9using System.Collections;
10using System.Collections.Generic;
28 if (target is IManageProperties imp)
30 var targetProperties = imp.GetManagedProperties();
31 foreach (var item
in targetProperties)
74 CopyField(source, target,
"_isDirty");
75 CopyField(source, target,
"_isNew");
76 CopyField(source, target,
"_isDeleted");
82 private static void CopyField(
object source,
object target,
string fieldName)
84 if (source ==
null)
return;
85 if (target ==
null)
return;
86 var sourceField = source.GetType().GetField(fieldName, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic);
87 if (sourceField !=
null)
89 var targetField = target.GetType().GetField(fieldName, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic);
90 if (targetField!=
null)
92 targetField.SetValue(target, sourceField.GetValue(source));
102 private void MergeGraph(IEditableCollection target, IEditableCollection source)
105 var listType = target.GetType();
106 var childType = Utilities.GetChildItemType(listType);
107 var genericTypeParams =
new Type[] { listType, childType };
108 var parameterTypes =
new Type[] { listType, listType };
109 var methodReference = this.GetType().GetMethod(
"MergeBusinessListGraph");
110 var gr = methodReference.MakeGenericMethod(genericTypeParams);
111 gr.Invoke(
this,
new object[] { target, source });
122 where C : Core.IEditableBusinessObject
124 var deleted =
new List<C>();
125 foreach (var item
in target)
127 var sourceItem = source.Where(_ => _.Identity == item.Identity).FirstOrDefault();
128 if (sourceItem !=
null)
135 foreach (var item
in source)
136 if (target.Count(_ => _.Identity == item.Identity) == 0)
140 foreach (var item
in deleted)
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).
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 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...