Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / Model / EditingScope.cs / 1305376 / EditingScope.cs
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//---------------------------------------------------------------
namespace System.Activities.Presentation.Model
{
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime;
[Fx.Tag.XamlVisible(false)]
public class EditingScope : ModelEditingScope
{
ModelTreeManager modelTreeManager;
EditingScope outerScope;
List changes;
List appliedChanges;
bool suppressUndo;
internal EditingScope(ModelTreeManager modelTreeManager, EditingScope outerScope)
{
this.modelTreeManager = modelTreeManager;
this.changes = new List();
this.outerScope = outerScope;
this.HasModelChanges = false;
}
private EditingScope()
{
}
public bool HasEffectiveChanges
{
get
{
return this.appliedChanges != null && this.appliedChanges.Count > 0;
}
}
internal bool HasModelChanges
{
get;
private set;
}
internal bool SuppressUndo
{
get
{
return this.suppressUndo;
}
set
{
Fx.Assert(!value || this.outerScope == null, "If we are suppressing undo, then we are not nested within another editingScope, otherwise suppress undo won't work.");
this.suppressUndo = value;
}
}
public List Changes
{
get
{
return changes;
}
}
protected override void OnComplete()
{
if (this.outerScope == null)
{
appliedChanges = new List();
int startIndex = 0;
// pump all changes, applying changes can add more changes to the end of the change list.
while (startIndex < this.Changes.Count)
{
// pickup the new changes
List changesToApply = this.Changes.GetRange(startIndex, this.Changes.Count - startIndex);
startIndex = this.Changes.Count;
foreach (Change change in changesToApply)
{
if (change != null && change.Apply())
{
appliedChanges.Add(change);
}
if (change is ModelChange)
{
this.HasModelChanges = true;
}
}
}
}
else
{
outerScope.Changes.AddRange(this.Changes);
}
this.modelTreeManager.OnEditingScopeCompleted(this);
}
protected override bool CanComplete()
{
return this.modelTreeManager.CanEditingScopeComplete(this);
}
protected override void OnRevert(bool finalizing)
{
if (this.appliedChanges != null)
{
List revertChanges = new List();
foreach (Change change in this.appliedChanges)
{
revertChanges.Add(change.GetInverse());
}
revertChanges.Reverse();
foreach (Change change in revertChanges)
{
change.Apply();
this.appliedChanges.RemoveAt(this.appliedChanges.Count - 1);
}
}
this.modelTreeManager.OnEditingScopeReverted(this);
}
protected override bool OnException(Exception e)
{
return false;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//---------------------------------------------------------------
namespace System.Activities.Presentation.Model
{
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime;
[Fx.Tag.XamlVisible(false)]
public class EditingScope : ModelEditingScope
{
ModelTreeManager modelTreeManager;
EditingScope outerScope;
List changes;
List appliedChanges;
bool suppressUndo;
internal EditingScope(ModelTreeManager modelTreeManager, EditingScope outerScope)
{
this.modelTreeManager = modelTreeManager;
this.changes = new List();
this.outerScope = outerScope;
this.HasModelChanges = false;
}
private EditingScope()
{
}
public bool HasEffectiveChanges
{
get
{
return this.appliedChanges != null && this.appliedChanges.Count > 0;
}
}
internal bool HasModelChanges
{
get;
private set;
}
internal bool SuppressUndo
{
get
{
return this.suppressUndo;
}
set
{
Fx.Assert(!value || this.outerScope == null, "If we are suppressing undo, then we are not nested within another editingScope, otherwise suppress undo won't work.");
this.suppressUndo = value;
}
}
public List Changes
{
get
{
return changes;
}
}
protected override void OnComplete()
{
if (this.outerScope == null)
{
appliedChanges = new List();
int startIndex = 0;
// pump all changes, applying changes can add more changes to the end of the change list.
while (startIndex < this.Changes.Count)
{
// pickup the new changes
List changesToApply = this.Changes.GetRange(startIndex, this.Changes.Count - startIndex);
startIndex = this.Changes.Count;
foreach (Change change in changesToApply)
{
if (change != null && change.Apply())
{
appliedChanges.Add(change);
}
if (change is ModelChange)
{
this.HasModelChanges = true;
}
}
}
}
else
{
outerScope.Changes.AddRange(this.Changes);
}
this.modelTreeManager.OnEditingScopeCompleted(this);
}
protected override bool CanComplete()
{
return this.modelTreeManager.CanEditingScopeComplete(this);
}
protected override void OnRevert(bool finalizing)
{
if (this.appliedChanges != null)
{
List revertChanges = new List();
foreach (Change change in this.appliedChanges)
{
revertChanges.Add(change.GetInverse());
}
revertChanges.Reverse();
foreach (Change change in revertChanges)
{
change.Apply();
this.appliedChanges.RemoveAt(this.appliedChanges.Count - 1);
}
}
this.modelTreeManager.OnEditingScopeReverted(this);
}
protected override bool OnException(Exception e)
{
return false;
}
}
}
// 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
- UserNameServiceElement.cs
- ElementNotEnabledException.cs
- PreservationFileReader.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- BamlLocalizableResourceKey.cs
- ConfigWriter.cs
- ReadWriteObjectLock.cs
- TrackingMemoryStream.cs
- InputLangChangeRequestEvent.cs
- Empty.cs
- MapPathBasedVirtualPathProvider.cs
- PropVariant.cs
- BaseTemplateCodeDomTreeGenerator.cs
- isolationinterop.cs
- BrowserDefinition.cs
- HebrewNumber.cs
- WbmpConverter.cs
- XmlCodeExporter.cs
- UnsafeNativeMethodsMilCoreApi.cs
- IntSecurity.cs
- DataGridViewTopLeftHeaderCell.cs
- SafeTokenHandle.cs
- ThreadInterruptedException.cs
- OdbcParameterCollection.cs
- OciEnlistContext.cs
- SqlCaseSimplifier.cs
- xmlfixedPageInfo.cs
- SqlDelegatedTransaction.cs
- ReadOnlyPropertyMetadata.cs
- HotSpotCollectionEditor.cs
- Mapping.cs
- FrameworkContextData.cs
- FileLogRecordStream.cs
- URL.cs
- ToolStripRendererSwitcher.cs
- basecomparevalidator.cs
- HttpRuntime.cs
- WsdlInspector.cs
- SqlDependencyUtils.cs
- HtmlElementErrorEventArgs.cs
- ReadContentAsBinaryHelper.cs
- Baml6ConstructorInfo.cs
- MergeLocalizationDirectives.cs
- RelationshipEndMember.cs
- RowBinding.cs
- TextDocumentView.cs
- ResourceReferenceKeyNotFoundException.cs
- DesignSurfaceCollection.cs
- NamespaceExpr.cs
- BatchServiceHost.cs
- BCryptSafeHandles.cs
- XmlElement.cs
- HtmlInputRadioButton.cs
- DataGrid.cs
- PostBackOptions.cs
- TcpChannelListener.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- RSAPKCS1KeyExchangeFormatter.cs
- SubMenuStyleCollection.cs
- CodeAttributeDeclarationCollection.cs
- CharacterString.cs
- ImageBrush.cs
- CachedFontFace.cs
- ComPlusSynchronizationContext.cs
- DataGridViewCellStyle.cs
- GroupBox.cs
- ResetableIterator.cs
- StateMachineWorkflowDesigner.cs
- WinFormsUtils.cs
- diagnosticsswitches.cs
- SchemaNames.cs
- _NativeSSPI.cs
- ByteAnimationUsingKeyFrames.cs
- OAVariantLib.cs
- EventBookmark.cs
- WindowProviderWrapper.cs
- BrushValueSerializer.cs
- RSAPKCS1SignatureFormatter.cs
- SchemaCollectionPreprocessor.cs
- HttpHostedTransportConfiguration.cs
- Parsers.cs
- XmlTextReaderImpl.cs
- JsonReader.cs
- DocumentGrid.cs
- MarkupCompilePass1.cs
- CodeDomExtensionMethods.cs
- QilLiteral.cs
- SHA512Managed.cs
- GlobalizationAssembly.cs
- _AutoWebProxyScriptEngine.cs
- basenumberconverter.cs
- AutoGeneratedField.cs
- CodeBinaryOperatorExpression.cs
- SecurityManager.cs
- AuthenticationServiceManager.cs
- StringStorage.cs
- PerspectiveCamera.cs
- StorageAssociationSetMapping.cs
- InstanceHandleConflictException.cs
- IERequestCache.cs