/// <summary> /// Loads the old values. /// </summary> private void loadOldValues() { if (isInLoad) { return; } isInLoad = true; try { OldValues.Clear(); var session = ((ISessionProvider)TargetObject).Session; var classInfo = session.GetClassInfo(TargetObject); foreach (var member in classInfo.Members) { if (!(member is ServiceField) && !member.IsCollection && !TrackedObjectBag.SessionData.Collector.IsNotForProtocol(classInfo.ClassType) && !TrackedObjectBag.SessionData.Collector.IsNotForProtocol(classInfo.ClassType, member.Name) && !member.Owner.ClassType.IsAssignableFrom(typeof(XPBaseObject))) { OldValues.Add(member.Name, member.GetValue(TargetObject)); } } } finally { isInLoad = false; } }
public void SaveCurrentState() { if (IsSaveCurrentState) { return; } else { OldValues.Clear(); IsSaveCurrentState = true; } foreach (var item in Items) { if (item is IResettable r && !ResetExeclusions.Contains(r)) { r.SaveCurrentState(); } } foreach (var item in InternalDictionary) { if (!PropertyResetExeclusions.Contains(item.Key) && item.Value.Value is IResettable ro && !ResetExeclusions.Contains(ro)) { ro.SaveCurrentState(); } } IsSaveCurrentState = false; }
public void Reset() { if (IsReset) { return; } else { foreach (var item in OldValues) { if (item.Key == nameof(Count)) { continue; } SetPropertyValue(item.Value, item.Key); } OldValues.Clear(); IsReset = true; } foreach (var item in Items) { if (item is IResettable r && !ResetExeclusions.Contains(r)) { r.Reset(); } } foreach (var item in InternalDictionary) { if (!PropertyResetExeclusions.Contains(item.Key) && item.Value.Value is IResettable ro && !ResetExeclusions.Contains(ro)) { ro.Reset(); } } IsReset = false; }
/// <summary> /// Closes this instance. /// </summary> public void Close() { unSubscribeFromCollectionChanges(); OldValues.Clear(); }