Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / 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(); } } }
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AnnotationMap.cs
- PropertyGridDesigner.cs
- ExternalException.cs
- ControlBuilderAttribute.cs
- WebPartEditorCancelVerb.cs
- HexParser.cs
- CustomWebEventKey.cs
- InstanceHandleConflictException.cs
- PageVisual.cs
- IERequestCache.cs
- ControlPaint.cs
- HttpCapabilitiesSectionHandler.cs
- MemberJoinTreeNode.cs
- WindowsAuthenticationEventArgs.cs
- FilterQueryOptionExpression.cs
- CompositeControl.cs
- EmbeddedMailObjectsCollection.cs
- ToolStripDropDownButton.cs
- Single.cs
- CacheForPrimitiveTypes.cs
- SecurityCapabilities.cs
- ComponentDesigner.cs
- TypePropertyEditor.cs
- TextEffect.cs
- SqlConnection.cs
- EntityWrapper.cs
- RotationValidation.cs
- TextContainer.cs
- LocationReferenceEnvironment.cs
- TextureBrush.cs
- TrackingMemoryStreamFactory.cs
- GridViewColumnCollectionChangedEventArgs.cs
- PingReply.cs
- GraphicsContainer.cs
- ProviderBase.cs
- SQLDateTime.cs
- SmtpMail.cs
- DesignSurfaceServiceContainer.cs
- ConfigXmlSignificantWhitespace.cs
- TransformerConfigurationWizardBase.cs
- StateRuntime.cs
- SecurityRuntime.cs
- ProfileEventArgs.cs
- TreeIterator.cs
- OleDbEnumerator.cs
- MDIWindowDialog.cs
- AssociatedControlConverter.cs
- SEHException.cs
- CannotUnloadAppDomainException.cs
- Column.cs
- EntityDataSourceSelectingEventArgs.cs
- EntryPointNotFoundException.cs
- TextLineBreak.cs
- RegexCode.cs
- ToolStripArrowRenderEventArgs.cs
- ServerIdentity.cs
- ProviderUtil.cs
- AttributeEmitter.cs
- ImportContext.cs
- TripleDES.cs
- ConfigXmlSignificantWhitespace.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- CloseSequence.cs
- TypeResolvingOptions.cs
- WebBrowserUriTypeConverter.cs
- CustomActivityDesigner.cs
- XPathDocumentIterator.cs
- DateTime.cs
- ReferenceEqualityComparer.cs
- DebugController.cs
- ConfigurationStrings.cs
- TextSelection.cs
- DataRecord.cs
- DependencyPropertyAttribute.cs
- ObjectQueryProvider.cs
- Expression.cs
- TrackBarDesigner.cs
- SizeFConverter.cs
- QueryStatement.cs
- HandlerBase.cs
- EntityDataSourceEntitySetNameItem.cs
- EventLogPermissionEntry.cs
- DataControlExtensions.cs
- WebBrowser.cs
- Module.cs
- TableLayoutRowStyleCollection.cs
- ProcessProtocolHandler.cs
- ISessionStateStore.cs
- StateRuntime.cs
- PageTrueTypeFont.cs
- ParsedAttributeCollection.cs
- AutomationPropertyInfo.cs
- ListViewGroup.cs
- Lazy.cs
- AutoResizedEvent.cs
- HttpProfileBase.cs
- Part.cs
- DoubleConverter.cs
- dataSvcMapFileLoader.cs
- ExpressionTextBoxAutomationPeer.cs