Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- AspNetRouteServiceHttpHandler.cs
- TextContainerChangeEventArgs.cs
- SingleAnimationBase.cs
- RenderData.cs
- SqlCacheDependencySection.cs
- SequentialWorkflowRootDesigner.cs
- ErrorTableItemStyle.cs
- FloaterBaseParagraph.cs
- xmlsaver.cs
- FileLogRecord.cs
- WrapPanel.cs
- MailAddressCollection.cs
- MediaContext.cs
- TextSearch.cs
- FindCriteria11.cs
- ScalarRestriction.cs
- CalendarItem.cs
- FilteredXmlReader.cs
- FastEncoder.cs
- MediaContextNotificationWindow.cs
- OlePropertyStructs.cs
- InkCanvasSelection.cs
- AuthenticationException.cs
- InlineObject.cs
- TreeBuilder.cs
- Size.cs
- DbMetaDataCollectionNames.cs
- WebPartCatalogCloseVerb.cs
- KnownBoxes.cs
- ClientApiGenerator.cs
- Matrix3D.cs
- Faults.cs
- TemplateInstanceAttribute.cs
- PointLightBase.cs
- TableMethodGenerator.cs
- ProfileModule.cs
- ValidationRule.cs
- ProfileEventArgs.cs
- ScriptingScriptResourceHandlerSection.cs
- ObjectSpanRewriter.cs
- DbSourceCommand.cs
- TargetControlTypeAttribute.cs
- SamlAttribute.cs
- DesignerAdRotatorAdapter.cs
- XmlDataProvider.cs
- ObjectConverter.cs
- RotateTransform.cs
- IdentifierCreationService.cs
- TransformCollection.cs
- HttpResponseInternalWrapper.cs
- ScrollBarAutomationPeer.cs
- Animatable.cs
- Expression.cs
- dbenumerator.cs
- TransportSecurityHelpers.cs
- ThicknessAnimationBase.cs
- EnumerableRowCollectionExtensions.cs
- DbParameterHelper.cs
- XsltOutput.cs
- Positioning.cs
- UserPersonalizationStateInfo.cs
- GACIdentityPermission.cs
- DataGridViewRowPostPaintEventArgs.cs
- ToolBarButtonClickEvent.cs
- MachineKeyConverter.cs
- EditorPartCollection.cs
- DataGridViewIntLinkedList.cs
- TypeReference.cs
- RecordsAffectedEventArgs.cs
- TopClause.cs
- ToolStripHighContrastRenderer.cs
- ScrollChrome.cs
- LoginStatusDesigner.cs
- CookielessHelper.cs
- EncoderBestFitFallback.cs
- RadioButtonList.cs
- Point3D.cs
- Clause.cs
- TemplateColumn.cs
- ValidatedMobileControlConverter.cs
- StrongNamePublicKeyBlob.cs
- PerspectiveCamera.cs
- SerializationInfoEnumerator.cs
- DictionaryCustomTypeDescriptor.cs
- XmlBindingWorker.cs
- MetadataArtifactLoaderCompositeFile.cs
- IsolatedStorageException.cs
- DataQuery.cs
- EffectiveValueEntry.cs
- XmlILAnnotation.cs
- IntSecurity.cs
- SafeRegistryKey.cs
- CompilerResults.cs
- TabControl.cs
- ReliabilityContractAttribute.cs
- InertiaRotationBehavior.cs
- ToolStripDropDownClosedEventArgs.cs
- DotExpr.cs
- WindowsListBox.cs
- ZoneIdentityPermission.cs