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
- FontSourceCollection.cs
- PersonalizationAdministration.cs
- DesignerDataView.cs
- EventMappingSettingsCollection.cs
- TextDecoration.cs
- LambdaSerializationException.cs
- TypeBuilder.cs
- TabControlEvent.cs
- MouseOverProperty.cs
- OleTxTransaction.cs
- NumericExpr.cs
- XmlElement.cs
- ImageListUtils.cs
- FixedDocumentSequencePaginator.cs
- SafeCloseHandleCritical.cs
- Win32.cs
- EntityKey.cs
- CodeGroup.cs
- VisualProxy.cs
- ApplicationId.cs
- Automation.cs
- RequestCache.cs
- ConfigurationManagerHelper.cs
- HashJoinQueryOperatorEnumerator.cs
- WinInetCache.cs
- Binding.cs
- OuterGlowBitmapEffect.cs
- Journal.cs
- ImageFormatConverter.cs
- PixelFormatConverter.cs
- SqlDataRecord.cs
- DataGridViewColumnCollection.cs
- DecoderBestFitFallback.cs
- WSSecurityOneDotZeroSendSecurityHeader.cs
- TypeContext.cs
- BufferAllocator.cs
- MaskedTextBoxTextEditor.cs
- COM2ICategorizePropertiesHandler.cs
- SchemaExporter.cs
- EndpointInstanceProvider.cs
- WindowsStatusBar.cs
- Pen.cs
- WinEventWrap.cs
- LassoSelectionBehavior.cs
- PropertyMapper.cs
- MD5Cng.cs
- PeerCollaborationPermission.cs
- wgx_render.cs
- _LoggingObject.cs
- BindingsCollection.cs
- ObjectDataSourceDisposingEventArgs.cs
- PeerName.cs
- PerspectiveCamera.cs
- PopupControlService.cs
- Zone.cs
- TextSchema.cs
- ExtentJoinTreeNode.cs
- InvalidPrinterException.cs
- Renderer.cs
- XmlSchemaProviderAttribute.cs
- RadioButton.cs
- SqlBulkCopyColumnMappingCollection.cs
- SmiConnection.cs
- SymmetricAlgorithm.cs
- SoapCodeExporter.cs
- TypeSource.cs
- DynamicPropertyReader.cs
- WindowsContainer.cs
- MarkupCompiler.cs
- InputProcessorProfilesLoader.cs
- TypeConstant.cs
- CreateParams.cs
- SecUtil.cs
- DragDrop.cs
- FrameworkRichTextComposition.cs
- DeferredElementTreeState.cs
- DesignerSelectionListAdapter.cs
- SrgsItemList.cs
- SafeRightsManagementSessionHandle.cs
- MultipartIdentifier.cs
- XmlSchemaSimpleContent.cs
- Symbol.cs
- MailHeaderInfo.cs
- figurelength.cs
- TextComposition.cs
- SmtpException.cs
- StringToken.cs
- InternalMappingException.cs
- ClrPerspective.cs
- FormViewPageEventArgs.cs
- HttpCookie.cs
- Control.cs
- DropSource.cs
- Automation.cs
- VectorConverter.cs
- SearchForVirtualItemEventArgs.cs
- NestedContainer.cs
- FormViewPageEventArgs.cs
- TypeUsage.cs
- XmlSchemaInferenceException.cs