Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / CompMod / System / ComponentModel / Design / DesignerTransaction.cs / 1 / DesignerTransaction.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.ComponentModel.Design { using System; using System.Security.Permissions; ////// Identifies a transaction within a designer. Transactions are /// used to wrap serveral changes into one unit of work, which /// helps performance. /// [HostProtection(SharedState = true)] [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name = "FullTrust")] public abstract class DesignerTransaction : IDisposable { private bool committed = false; private bool canceled = false; private bool suppressedFinalization = false; private string desc; ////// protected DesignerTransaction() : this("") { } ///[To be supplied.] ////// protected DesignerTransaction(string description) { this.desc = description; } ///[To be supplied.] ////// public bool Canceled { get { return canceled; } } ///[To be supplied.] ////// public bool Committed { get { return committed; } } ///[To be supplied.] ////// public string Description { get { return desc; } } ///[To be supplied.] ////// public void Cancel() { if (!canceled && !committed) { canceled = true; GC.SuppressFinalize(this); suppressedFinalization = true; OnCancel(); } } ///[To be supplied.] ////// Commits this transaction. Once a transaction has /// been committed, further calls to this method /// will do nothing. You should always call this /// method after creating a transaction to ensure /// that the transaction is closed properly. /// public void Commit() { if (!committed && !canceled) { committed = true; GC.SuppressFinalize(this); suppressedFinalization = true; OnCommit(); } } ////// User code should implement this method to perform /// the actual work of committing a transaction. /// protected abstract void OnCancel(); ////// User code should implement this method to perform /// the actual work of committing a transaction. /// protected abstract void OnCommit(); ////// Overrides Object to commit this transaction /// in case the user forgot. /// ~DesignerTransaction() { Dispose(false); } ////// /// Private implementation of IDisaposable. /// When a transaction is disposed it is /// committed. /// void IDisposable.Dispose() { Dispose(true); // note - Dispose calls Cancel which sets this bit, so // this should never be hit. // if (!suppressedFinalization) { System.Diagnostics.Debug.Fail("Invalid state. Dispose(true) should have called cancel which does the SuppressFinalize"); GC.SuppressFinalize(this); } } protected virtual void Dispose(bool disposing) { System.Diagnostics.Debug.Assert(disposing, "Designer transaction garbage collected, unable to cancel, please Cancel, Close, or Dispose your transaction."); System.Diagnostics.Debug.Assert(disposing || canceled || committed, "Disposing DesignerTransaction that has not been comitted or canceled; forcing Cancel" ); Cancel(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.ComponentModel.Design { using System; using System.Security.Permissions; ////// Identifies a transaction within a designer. Transactions are /// used to wrap serveral changes into one unit of work, which /// helps performance. /// [HostProtection(SharedState = true)] [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name = "FullTrust")] public abstract class DesignerTransaction : IDisposable { private bool committed = false; private bool canceled = false; private bool suppressedFinalization = false; private string desc; ////// protected DesignerTransaction() : this("") { } ///[To be supplied.] ////// protected DesignerTransaction(string description) { this.desc = description; } ///[To be supplied.] ////// public bool Canceled { get { return canceled; } } ///[To be supplied.] ////// public bool Committed { get { return committed; } } ///[To be supplied.] ////// public string Description { get { return desc; } } ///[To be supplied.] ////// public void Cancel() { if (!canceled && !committed) { canceled = true; GC.SuppressFinalize(this); suppressedFinalization = true; OnCancel(); } } ///[To be supplied.] ////// Commits this transaction. Once a transaction has /// been committed, further calls to this method /// will do nothing. You should always call this /// method after creating a transaction to ensure /// that the transaction is closed properly. /// public void Commit() { if (!committed && !canceled) { committed = true; GC.SuppressFinalize(this); suppressedFinalization = true; OnCommit(); } } ////// User code should implement this method to perform /// the actual work of committing a transaction. /// protected abstract void OnCancel(); ////// User code should implement this method to perform /// the actual work of committing a transaction. /// protected abstract void OnCommit(); ////// Overrides Object to commit this transaction /// in case the user forgot. /// ~DesignerTransaction() { Dispose(false); } ////// /// Private implementation of IDisaposable. /// When a transaction is disposed it is /// committed. /// void IDisposable.Dispose() { Dispose(true); // note - Dispose calls Cancel which sets this bit, so // this should never be hit. // if (!suppressedFinalization) { System.Diagnostics.Debug.Fail("Invalid state. Dispose(true) should have called cancel which does the SuppressFinalize"); GC.SuppressFinalize(this); } } protected virtual void Dispose(bool disposing) { System.Diagnostics.Debug.Assert(disposing, "Designer transaction garbage collected, unable to cancel, please Cancel, Close, or Dispose your transaction."); System.Diagnostics.Debug.Assert(disposing || canceled || committed, "Disposing DesignerTransaction that has not been comitted or canceled; forcing Cancel" ); Cancel(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- OleDbConnectionPoolGroupProviderInfo.cs
- ValidationHelper.cs
- SchemaNamespaceManager.cs
- SoapIgnoreAttribute.cs
- GridViewRow.cs
- XmlStreamNodeWriter.cs
- StyleCollection.cs
- SqlBinder.cs
- ConnectionStringsExpressionBuilder.cs
- DataMemberFieldConverter.cs
- DoubleConverter.cs
- X509Certificate.cs
- StaticFileHandler.cs
- TreeViewCancelEvent.cs
- SecurityElementBase.cs
- DSASignatureDeformatter.cs
- UnsafeNativeMethods.cs
- ParameterExpression.cs
- UseAttributeSetsAction.cs
- BamlLocalizableResourceKey.cs
- HttpListenerPrefixCollection.cs
- DataGridViewRowPrePaintEventArgs.cs
- AssertFilter.cs
- NullableBoolConverter.cs
- ListDictionaryInternal.cs
- XmlUtil.cs
- DiffuseMaterial.cs
- ClaimSet.cs
- AndCondition.cs
- DataSourceProvider.cs
- ZoneMembershipCondition.cs
- AdapterUtil.cs
- Vector3DAnimationBase.cs
- CultureTableRecord.cs
- FlowDocumentReaderAutomationPeer.cs
- Certificate.cs
- PersianCalendar.cs
- SqlUtil.cs
- StructureChangedEventArgs.cs
- RadioButton.cs
- LifetimeMonitor.cs
- PKCS1MaskGenerationMethod.cs
- DynamicDataResources.Designer.cs
- ConfigXmlElement.cs
- AbandonedMutexException.cs
- DependencyPropertyKind.cs
- PackWebRequest.cs
- ProxyWebPart.cs
- ProfessionalColorTable.cs
- PixelFormats.cs
- Single.cs
- BmpBitmapEncoder.cs
- _ConnectOverlappedAsyncResult.cs
- WebBrowserDocumentCompletedEventHandler.cs
- SqlDataSourceStatusEventArgs.cs
- XmlComment.cs
- Stopwatch.cs
- ProcessThread.cs
- FlatButtonAppearance.cs
- Visual3D.cs
- DetailsViewModeEventArgs.cs
- oledbconnectionstring.cs
- BrowserCapabilitiesCodeGenerator.cs
- XamlHttpHandlerFactory.cs
- ErrorTolerantObjectWriter.cs
- PassportAuthenticationEventArgs.cs
- nulltextnavigator.cs
- RadioButtonBaseAdapter.cs
- IsolatedStorageSecurityState.cs
- PrintPreviewDialog.cs
- TransformerTypeCollection.cs
- TextEditorContextMenu.cs
- RightsManagementEncryptionTransform.cs
- HtmlTableCell.cs
- ContextMenuService.cs
- EventLogEntryCollection.cs
- HttpCacheVaryByContentEncodings.cs
- ContainerControl.cs
- ComponentChangedEvent.cs
- DictationGrammar.cs
- Convert.cs
- DLinqDataModelProvider.cs
- SoapElementAttribute.cs
- XPathAncestorQuery.cs
- ObjectItemConventionAssemblyLoader.cs
- Faults.cs
- DrawingState.cs
- SynchronizationContext.cs
- GCHandleCookieTable.cs
- HttpConfigurationSystem.cs
- OdbcEnvironment.cs
- DefaultSettingsSection.cs
- HttpModuleActionCollection.cs
- PeerTransportListenAddressValidatorAttribute.cs
- DateTimeOffsetStorage.cs
- BinaryMessageFormatter.cs
- DataProviderNameConverter.cs
- ActiveXHost.cs
- InstancePersistenceContext.cs
- PositiveTimeSpanValidatorAttribute.cs