/// <summary> /// Commit the changes made to the object since the last time 'CreateSnapshot' was called. /// </summary> public void CommitSnapshot() { _bindingEdit = false; // We can only commit the changes if a snapshot was created. if (EditLevel > 0) { // Remove the last state from the stack. _stateStack.Pop(); // Check if the object contains other IUndoable types, so that // we can call CommitSnapshot on these fields as well. Type currentType; FieldInfo[] fields; currentType = this.GetType(); do { fields = currentType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo field in fields) { if (field.DeclaringType == currentType && this.IsUndoableField(field)) { object fieldValue = field.GetValue(this); IUndoable uf = fieldValue as IUndoable; if (uf != null) { uf.CommitSnapshot(); } } } currentType = currentType.BaseType; } while(currentType != typeof(BusinessObject)); } }