1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
5 namespace System.Activities.Presentation.Model
8 using System.Collections.Generic;
10 using System.Activities.Presentation.Services;
12 class DictionaryEditChange : ModelChange
14 public ModelItemDictionary Dictionary { get; set; }
16 public ModelItem Key { get; set; }
18 public ModelItem OldValue { get; set; }
20 public ModelItem NewValue { get; set; }
22 public ModelTreeManager ModelTreeManager { get; set; }
25 public override string Description
29 return SR.DictionaryEditEditingScopeDescription;
33 public override bool Apply()
35 ModelItem oldValue = this.Dictionary[this.Key];
36 if ((oldValue == null && this.NewValue == null) ||
37 (oldValue != null && this.NewValue != null && oldValue.GetCurrentValue().Equals(this.NewValue.GetCurrentValue())))
42 ((ModelItemDictionaryImpl)this.Dictionary).EditCore(this.Key, this.NewValue);
44 ModelChangeInfo changeInfo = ModelChangeInfoImpl.CreateDictionaryValueChanged(this.Dictionary, this.Key, this.OldValue, this.NewValue);
46 if (this.OldValue != null)
48 this.ModelTreeManager.modelService.OnModelItemRemoved(this.OldValue, changeInfo);
51 if (this.NewValue != null)
53 this.ModelTreeManager.modelService.OnModelItemAdded(this.NewValue, changeInfo);
60 public override Change GetInverse()
62 return new DictionaryEditChange()
64 Dictionary = this.Dictionary,
66 OldValue = this.NewValue,
67 NewValue = this.OldValue,
68 ModelTreeManager = this.ModelTreeManager,