/// <summary> /// Fires the ChangesApplied event. If an original object IDescriptor has been set, /// then this directly handles the update. /// </summary> protected virtual void OnChangesApplied() { if (OriginalObject != null) { OriginalObject.CopyProperties(PropertyGrid.SelectedObject); } if (ChangesApplied != null) { ChangesApplied(this, new EventArgs()); } }
private void mementoPatternBtn_Click(object sender, RoutedEventArgs e) { OriginalObject original = new OriginalObject("Testing", "Memento Pattern"); statusBarTB.Text = original.String1 + ", " + original.String2 + " | "; original.String1 = "Try change"; original.String2 = "original object"; statusBarTB.Text += original.String1 + ", " + original.String2 + " | "; original.Revert(); statusBarTB.Text += original.String1 + ", " + original.String2 + " "; }
/// <summary> /// Fires the ChangesApplied event. If an original object IDescriptor has been set, /// then this directly handles the update. /// </summary> protected virtual void OnChangesApplied() { OriginalObject?.CopyProperties(PropertyGrid.SelectedObject); ChangesApplied?.Invoke(this, EventArgs.Empty); }
public ModelBase() { OriginalObject = (T)Activator.CreateInstance <T>(); ModifiedObject = OriginalObject.Clone(); }