mscorlib(4.0.0.0) API with additions
DesignerTransaction.cs
2 
4 {
6  [HostProtection(SecurityAction.LinkDemand, SharedState = true)]
7  [PermissionSet(SecurityAction.InheritanceDemand, Name = "FullTrust")]
8  public abstract class DesignerTransaction : IDisposable
9  {
10  private bool committed;
11 
12  private bool canceled;
13 
14  private bool suppressedFinalization;
15 
16  private string desc;
17 
21  public bool Canceled => canceled;
22 
26  public bool Committed => committed;
27 
30  public string Description => desc;
31 
33  protected DesignerTransaction()
34  : this("")
35  {
36  }
37 
40  protected DesignerTransaction(string description)
41  {
42  desc = description;
43  }
44 
46  public void Cancel()
47  {
48  if (!canceled && !committed)
49  {
50  canceled = true;
51  GC.SuppressFinalize(this);
52  suppressedFinalization = true;
53  OnCancel();
54  }
55  }
56 
58  public void Commit()
59  {
60  if (!committed && !canceled)
61  {
62  committed = true;
63  GC.SuppressFinalize(this);
64  suppressedFinalization = true;
65  OnCommit();
66  }
67  }
68 
70  protected abstract void OnCancel();
71 
73  protected abstract void OnCommit();
74 
77  {
78  Dispose(disposing: false);
79  }
80 
82  void IDisposable.Dispose()
83  {
84  Dispose(disposing: true);
85  if (!suppressedFinalization)
86  {
87  GC.SuppressFinalize(this);
88  }
89  }
90 
94  protected virtual void Dispose(bool disposing)
95  {
96  Cancel();
97  }
98  }
99 }
abstract void OnCancel()
Raises the Cancel event.
abstract void OnCommit()
Performs the actual work of committing a transaction.
static void SuppressFinalize(object obj)
Requests that the common language runtime not call the finalizer for the specified object.
Definition: GC.cs:308
Provides a mechanism for releasing unmanaged resources.To browse the .NET Framework source code for t...
Definition: IDisposable.cs:8
Definition: __Canon.cs:3
string Description
Gets a description for the transaction.
SecurityAction
Specifies the security actions that can be performed using declarative security.
void Cancel()
Cancels the transaction and attempts to roll back the changes made by the events of the transaction.
virtual void Dispose(bool disposing)
Releases the unmanaged resources used by the T:System.ComponentModel.Design.DesignerTransaction and o...
bool Committed
Gets a value indicating whether the transaction was committed.
Controls the system garbage collector, a service that automatically reclaims unused memory.
Definition: GC.cs:11
bool Canceled
Gets a value indicating whether the transaction was canceled.
Provides a way to group a series of design-time actions to improve performance and enable most types ...
DesignerTransaction(string description)
Initializes a new instance of the T:System.ComponentModel.Design.DesignerTransaction class using the ...
DesignerTransaction()
Initializes a new instance of the T:System.ComponentModel.Design.DesignerTransaction class with no de...
void Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resourc...