Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / Model / DictionaryChange.cs / 1305376 / DictionaryChange.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; class DictionaryChange : ModelChange { public ModelItemDictionary Dictionary { get; set; } public OperationType Operation { get; set; } public ModelItem Key { get; set; } public ModelItem Value { get; set; } public ModelTreeManager ModelTreeManager { get; set; } public override string Description { get { return this.Operation == OperationType.Insert ? SR.DictionaryAddEditingScopeDescription : SR.DictionaryRemoveEditingScopeDescription; } } public override bool Apply() { switch (this.Operation) { case OperationType.Insert: ApplyInsert(); break; case OperationType.Delete: ApplyDelete(); break; default: Fx.Assert("Operation should be Insert or Delete"); break; } return true; } private void ApplyDelete() { ((ModelItemDictionaryImpl)this.Dictionary).RemoveCore(this.Key); ((IModelTreeItem)this.Key).RemoveParent(this.Dictionary); this.ModelTreeManager.ReleaseModelItem(this.Key, this.Dictionary); if (null != this.Value) { ((IModelTreeItem)this.Value).RemoveParent(this.Dictionary); } this.ModelTreeManager.ReleaseModelItem(this.Key, this.Dictionary); this.ModelTreeManager.modelService.OnModelItemRemoved(this.Key); if (null != this.Value) { this.ModelTreeManager.modelService.OnModelItemRemoved(this.Value); } } private void ApplyInsert() { this.ModelTreeManager.ReAddModelItemToModelTree(this.Key); this.ModelTreeManager.ReAddModelItemToModelTree(this.Value); ((ModelItemDictionaryImpl)this.Dictionary).AddCore(this.Key, this.Value); this.ModelTreeManager.modelService.OnModelItemAdded(this.Key); if (null != this.Value) { this.ModelTreeManager.modelService.OnModelItemAdded(this.Value); } } public override Change GetInverse() { OperationType reverseOperation = this.Operation == OperationType.Insert ? OperationType.Delete : OperationType.Insert; return new DictionaryChange() { Dictionary = this.Dictionary, Operation = reverseOperation, Key = this.Key, Value = this.Value, ModelTreeManager = this.ModelTreeManager, }; } public enum OperationType { Insert, Delete } } } // 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; class DictionaryChange : ModelChange { public ModelItemDictionary Dictionary { get; set; } public OperationType Operation { get; set; } public ModelItem Key { get; set; } public ModelItem Value { get; set; } public ModelTreeManager ModelTreeManager { get; set; } public override string Description { get { return this.Operation == OperationType.Insert ? SR.DictionaryAddEditingScopeDescription : SR.DictionaryRemoveEditingScopeDescription; } } public override bool Apply() { switch (this.Operation) { case OperationType.Insert: ApplyInsert(); break; case OperationType.Delete: ApplyDelete(); break; default: Fx.Assert("Operation should be Insert or Delete"); break; } return true; } private void ApplyDelete() { ((ModelItemDictionaryImpl)this.Dictionary).RemoveCore(this.Key); ((IModelTreeItem)this.Key).RemoveParent(this.Dictionary); this.ModelTreeManager.ReleaseModelItem(this.Key, this.Dictionary); if (null != this.Value) { ((IModelTreeItem)this.Value).RemoveParent(this.Dictionary); } this.ModelTreeManager.ReleaseModelItem(this.Key, this.Dictionary); this.ModelTreeManager.modelService.OnModelItemRemoved(this.Key); if (null != this.Value) { this.ModelTreeManager.modelService.OnModelItemRemoved(this.Value); } } private void ApplyInsert() { this.ModelTreeManager.ReAddModelItemToModelTree(this.Key); this.ModelTreeManager.ReAddModelItemToModelTree(this.Value); ((ModelItemDictionaryImpl)this.Dictionary).AddCore(this.Key, this.Value); this.ModelTreeManager.modelService.OnModelItemAdded(this.Key); if (null != this.Value) { this.ModelTreeManager.modelService.OnModelItemAdded(this.Value); } } public override Change GetInverse() { OperationType reverseOperation = this.Operation == OperationType.Insert ? OperationType.Delete : OperationType.Insert; return new DictionaryChange() { Dictionary = this.Dictionary, Operation = reverseOperation, Key = this.Key, Value = this.Value, ModelTreeManager = this.ModelTreeManager, }; } public enum OperationType { Insert, Delete } } } // 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
- HealthMonitoringSectionHelper.cs
- DispatchWrapper.cs
- BrowserCapabilitiesCompiler.cs
- DiscoveryVersion.cs
- ViewStateException.cs
- Error.cs
- DoubleCollection.cs
- XmlSchema.cs
- MissingManifestResourceException.cs
- BitmapFrameEncode.cs
- TabControlCancelEvent.cs
- ZipFileInfo.cs
- InputLanguageManager.cs
- HttpFileCollectionWrapper.cs
- XslCompiledTransform.cs
- DependencyProperty.cs
- MostlySingletonList.cs
- WebPartDescription.cs
- ServiceContractViewControl.Designer.cs
- GridViewSelectEventArgs.cs
- SimpleWorkerRequest.cs
- FormsAuthenticationUser.cs
- InboundActivityHelper.cs
- ReaderWriterLock.cs
- InternalResources.cs
- HitTestWithPointDrawingContextWalker.cs
- VisualStyleElement.cs
- TextModifierScope.cs
- PrincipalPermission.cs
- ExpressionVisitor.cs
- DataGridViewCellMouseEventArgs.cs
- RequestQueue.cs
- GeneralTransform3DGroup.cs
- ThreadBehavior.cs
- Int16.cs
- CodeRegionDirective.cs
- StickyNoteHelper.cs
- Profiler.cs
- CatalogZone.cs
- FrameworkRichTextComposition.cs
- XmlSchemaComplexType.cs
- ProbeDuplexCD1AsyncResult.cs
- XmlCustomFormatter.cs
- EpmSyndicationContentSerializer.cs
- PageAdapter.cs
- Buffer.cs
- SerializationHelper.cs
- BinaryUtilClasses.cs
- SqlRewriteScalarSubqueries.cs
- WebPartDeleteVerb.cs
- JsonDeserializer.cs
- ListViewUpdateEventArgs.cs
- ObjectViewQueryResultData.cs
- MexHttpsBindingCollectionElement.cs
- SqlXml.cs
- SqlNodeAnnotation.cs
- ServiceReference.cs
- xamlnodes.cs
- PreviewControlDesigner.cs
- ObjectSpanRewriter.cs
- FtpWebRequest.cs
- TextViewSelectionProcessor.cs
- SystemBrushes.cs
- MemberInfoSerializationHolder.cs
- AnnotationStore.cs
- GradientStopCollection.cs
- TableLayout.cs
- Set.cs
- SqlConnectionPoolGroupProviderInfo.cs
- CompressedStack.cs
- EntityDataSourceUtil.cs
- BitmapSource.cs
- DrawingContextDrawingContextWalker.cs
- KeyEventArgs.cs
- TextPointerBase.cs
- DuplicateWaitObjectException.cs
- SymmetricKey.cs
- CodeGroup.cs
- ObjectMemberMapping.cs
- Exception.cs
- LinqDataSourceDisposeEventArgs.cs
- ScrollViewer.cs
- FixedDocument.cs
- basevalidator.cs
- _NegoStream.cs
- WebHttpSecurityElement.cs
- DataGridViewDesigner.cs
- DPCustomTypeDescriptor.cs
- XmlLinkedNode.cs
- DataObjectFieldAttribute.cs
- Transform3D.cs
- UIElement3DAutomationPeer.cs
- DynamicResourceExtension.cs
- XmlSchemaAll.cs
- DataServiceRequestOfT.cs
- DNS.cs
- SystemIPGlobalStatistics.cs
- SimpleTextLine.cs
- ObjectViewQueryResultData.cs
- PersistChildrenAttribute.cs