コード例 #1
0
 // Captures the original value for a property that is changing.
 internal void RecordOriginalValue(string propertyName, object oldValue, object newValue)
 {
     if (IsChangeTrackingEnabled && _objectState != ObjectState.Added)
     {
         if (OriginalValues.ContainsKey(propertyName))
         {
             if (object.Equals(OriginalValues[propertyName], newValue))
             {
                 OriginalValues.Remove(propertyName);
                 if (OriginalValues.Count == 0 && _objectState == ObjectState.Modified)
                 {
                     State = ObjectState.Unchanged;
                     ModifiedProperties.Clear();
                 }
                 else
                 {
                     ModifiedProperties.Remove(propertyName);
                 }
             }
         }
         else
         {
             OriginalValues[propertyName] = oldValue;
         }
     }
 }
コード例 #2
0
 // Resets the ObjectChangeTracker to the Unchanged state and
 // clears the original values as well as the record of changes
 // to collection properties
 public void AcceptChanges()
 {
     ModifiedProperties.Clear();
     OriginalValues.Clear();
     ObjectsAddedToCollectionProperties.Clear();
     ObjectsRemovedFromCollectionProperties.Clear();
     IsChangeTrackingEnabled = true;
     State = ObjectState.Unchanged;
 }
コード例 #3
0
 /// <summary>
 /// Clears the changes.
 /// </summary>
 internal void ClearChanges()
 {
     ModifiedProperties.Clear();
     AddedObjects.Clear();
     DeletedObjects.Clear();
 }