80e0979330e9eb4abae81c5ae792e5a0633d5499
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Model / PropertyReferenceChange.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.Globalization;
10
11     internal class PropertyReferenceChange : ModelChange
12     {
13         public ModelItem Owner { get; set; }
14
15         public string TargetProperty { get; set; }
16
17         public string OldSourceProperty { get; set; }
18
19         public string NewSourceProperty { get; set; }
20
21         public override string Description
22         {
23             get
24             {
25                 return string.Format(CultureInfo.InvariantCulture, "{0} - {1}", SR.PropertyReferenceChangeEditingScopeDescription, this.TargetProperty);
26             }
27         }
28
29         public override bool Apply()
30         {
31             PropertyReferenceUtilities.SetPropertyReference(this.Owner.GetCurrentValue(), this.TargetProperty, this.NewSourceProperty);
32             this.Owner.OnPropertyReferenceChanged(this.TargetProperty);
33
34             return true;
35         }
36
37         public override Change GetInverse()
38         {
39             return new PropertyReferenceChange()
40             {
41                 Owner = this.Owner,
42                 TargetProperty = this.TargetProperty,
43                 OldSourceProperty = this.NewSourceProperty,
44                 NewSourceProperty = this.OldSourceProperty
45             };
46         }
47     }
48 }