[reflection] Coop handles icalls in System.Reflection and System.RuntimeTypeHandle...
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Model / AttachablePropertyChange.cs
1 //----------------------------------------------------------------
2 // <copyright company="Microsoft Corporation">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //----------------------------------------------------------------
6
7 namespace System.Activities.Presentation.Model
8 {
9     using System.Xaml;
10
11     internal class AttachablePropertyChange : ModelChange
12     {
13         public ModelItem Owner { get; set; }
14         
15         public AttachableMemberIdentifier AttachablePropertyIdentifier { get; set; }
16         
17         public object OldValue { get; set; }
18         
19         public object NewValue { get; set; }
20         
21         public string PropertyName { get; set; }
22
23         public override string Description
24         {
25             get { return SR.PropertyChangeEditingScopeDescription; }
26         }
27
28         public override bool Apply()
29         {
30             if (this.NewValue == null)
31             {
32                 AttachablePropertyServices.RemoveProperty(this.Owner.GetCurrentValue(), this.AttachablePropertyIdentifier);
33             }
34             else
35             {
36                 AttachablePropertyServices.SetProperty(this.Owner.GetCurrentValue(), this.AttachablePropertyIdentifier, this.NewValue);
37             }
38
39             // notify observer
40             if (!string.IsNullOrEmpty(this.PropertyName))
41             {
42                 ((IModelTreeItem)this.Owner).OnPropertyChanged(this.PropertyName);
43             }
44
45             return true;
46         }
47
48         public override Change GetInverse()
49         {
50             return new AttachablePropertyChange()
51             {
52                 Owner = this.Owner,
53                 AttachablePropertyIdentifier = this.AttachablePropertyIdentifier,
54                 OldValue = this.NewValue,
55                 NewValue = this.OldValue,
56                 PropertyName = this.PropertyName
57             };
58         }
59     }
60 }