Fix XMM scanning on Mac x86.
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Model / PropertyChange.cs
1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //----------------------------------------------------------------
4
5 namespace System.Activities.Presentation.Model
6 {
7     using System;
8     using System.Collections.Generic;
9     using System.Text;
10     using System.Globalization;
11     using System.Runtime;
12     using System.Activities.Presentation.Services;
13
14     class PropertyChange : ModelChange
15     {
16         public ModelItem Owner { get; set; }
17
18         public string PropertyName { get; set; }
19
20         public ModelItem OldValue { get; set; }
21
22         public ModelItem NewValue { get; set; }
23
24         public ModelTreeManager ModelTreeManager { get; set; }
25
26         public override string Description
27         {
28             get 
29             {
30                 return string.Format(CultureInfo.InvariantCulture, "{0} - {1}", SR.PropertyChangeEditingScopeDescription, this.PropertyName); 
31             }
32         }
33
34         public override bool Apply()
35         {
36             Fx.Assert(this.ModelTreeManager != null, "Modeltreemanager cannot be null");
37             Fx.Assert(this.Owner != null, "Owner modelitem cannot be null");
38             Fx.Assert(!String.IsNullOrEmpty(this.PropertyName), " property name cannot be null or emptry");
39             ModelPropertyImpl dataModelProperty = (ModelPropertyImpl)this.Owner.Properties[this.PropertyName];
40             ModelItem oldValue = dataModelProperty.Value;
41             if ((oldValue == null && this.NewValue == null) ||
42                 (oldValue != null && this.NewValue != null && oldValue.GetCurrentValue().Equals(this.NewValue.GetCurrentValue())))
43             {
44                 return false;
45             }
46             dataModelProperty.SetValueCore(this.NewValue);
47             ModelChangeInfo changeInfo = ModelChangeInfoImpl.CreatePropertyChanged(this.Owner, this.PropertyName, this.OldValue, this.NewValue);
48             this.ModelTreeManager.NotifyPropertyChange(dataModelProperty, changeInfo);
49             return true;
50         }
51
52         public override Change GetInverse()
53         {
54             return new PropertyChange()
55                 {
56                     ModelTreeManager = this.ModelTreeManager,
57                     Owner = this.Owner,
58                     OldValue = this.NewValue,
59                     NewValue = this.OldValue,
60                     PropertyName = this.PropertyName
61                 };
62         }
63     }
64 }