Skip to content

Commit 536520b

Browse files
jamesmcroftSergio0694
authored andcommitted
Updated ordering for ObservableObject methods
1 parent 2559668 commit 536520b

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

docs/mvvm/MigratingFromMvvmLight.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -49,92 +49,92 @@ Below are a list of migrations that will need to be performed if being used in y
4949

5050
### ObservableObject Methods
5151

52-
#### VerifyPropertyName ( string )
52+
#### Set<T> ( Expression, ref T, T )
5353

54-
There is no direct replacement for the `VerifyPropertyName(string)` method and any code using this should be altered or removed.
54+
`Set(Expression, ref T, T)` does not have a like-for-like method signature replacement.
55+
56+
However, `SetProperty(ref T, T, string)` provides the same functionality with additional performance benefits.
5557

5658
```csharp
5759
// MvvmLight
58-
this.VerifyPropertyName(nameof(this.MyProperty));
60+
this.Set(() => this.MyProperty, ref this.myProperty, value);
5961

6062
// Toolkit.Mvvm
61-
// No direct replacement, remove
63+
this.SetProperty(ref this.myProperty, value, nameof(this.MyProperty));
6264
```
6365

64-
#### RaisePropertyChanged ( string )
66+
Note, string parameter is not required if the method is being called from the property's setter as it is inferred from the caller member name.
6567

66-
`RaisePropertyChanged(string)` has a renamed direct replacement, `OnPropertyChanged(string)`.
68+
#### Set<T> ( string, ref T, T )
69+
70+
`Set<T>(string, ref T, T)` does not have a like-for-like method signature replacement.
71+
72+
However, `SetProperty<T>(ref T, T, string)` provides the same functionality with re-ordered parameters.
6773

6874
```csharp
6975
// MvvmLight
70-
this.RaisePropertyChanged(nameof(this.MyProperty));
76+
this.Set(nameof(this.MyProperty), ref this.myProperty, value);
7177

7278
// Toolkit.Mvvm
73-
this.OnPropertyChanged(nameof(this.MyProperty));
79+
this.SetProperty(ref this.myProperty, value, nameof(this.MyProperty));
7480
```
7581

7682
Note, string parameter is not required if the method is being called from the property's setter as it is inferred from the caller member name.
7783

78-
#### RaisePropertyChanged<T> ( Expression )
79-
80-
`RaisePropertyChanged<T>(Expression)` does not have a direct replacement.
84+
#### Set<T> ( ref T, T, string )
8185

82-
It is recommended for improved performance that you replace `RaisePropertyChanged<T>(Expression)` with the Toolkit's `OnPropertyChanged(string)` using the `nameof` keyword instead.
86+
`Set<T>(ref T, T, string)` has a renamed direct replacement, `SetProperty<T>(ref T, T, string)`.
8387

8488
```csharp
8589
// MvvmLight
86-
this.RaisePropertyChanged(() => this.MyProperty);
90+
this.Set(ref this.myProperty, value, nameof(this.MyProperty));
8791

8892
// Toolkit.Mvvm
89-
this.OnPropertyChanged(nameof(this.MyProperty));
93+
this.SetProperty(ref this.myProperty, value, nameof(this.MyProperty));
9094
```
9195

92-
#### Set<T> ( Expression, ref T, T )
96+
Note, string parameter is not required if the method is being called from the property's setter as it is inferred from the caller member name.
9397

94-
`Set(Expression, ref T, T)` does not have a like-for-like method signature replacement.
98+
#### RaisePropertyChanged ( string )
9599

96-
However, `SetProperty(ref T, T, string)` provides the same functionality with additional performance benefits.
100+
`RaisePropertyChanged(string)` has a renamed direct replacement, `OnPropertyChanged(string)`.
97101

98102
```csharp
99103
// MvvmLight
100-
this.Set(() => this.MyProperty, ref this.myProperty, value);
104+
this.RaisePropertyChanged(nameof(this.MyProperty));
101105

102106
// Toolkit.Mvvm
103-
this.SetProperty(ref this.myProperty, value, nameof(this.MyProperty));
107+
this.OnPropertyChanged(nameof(this.MyProperty));
104108
```
105109

106110
Note, string parameter is not required if the method is being called from the property's setter as it is inferred from the caller member name.
107111

108-
#### Set<T> ( string, ref T, T )
112+
#### RaisePropertyChanged<T> ( Expression )
109113

110-
`Set<T>(string, ref T, T)` does not have a like-for-like method signature replacement.
114+
`RaisePropertyChanged<T>(Expression)` does not have a direct replacement.
111115

112-
However, `SetProperty<T>(ref T, T, string)` provides the same functionality with re-ordered parameters.
116+
It is recommended for improved performance that you replace `RaisePropertyChanged<T>(Expression)` with the Toolkit's `OnPropertyChanged(string)` using the `nameof` keyword instead.
113117

114118
```csharp
115119
// MvvmLight
116-
this.Set(nameof(this.MyProperty), ref this.myProperty, value);
120+
this.RaisePropertyChanged(() => this.MyProperty);
117121

118122
// Toolkit.Mvvm
119-
this.SetProperty(ref this.myProperty, value, nameof(this.MyProperty));
123+
this.OnPropertyChanged(nameof(this.MyProperty));
120124
```
121125

122-
Note, string parameter is not required if the method is being called from the property's setter as it is inferred from the caller member name.
123-
124-
#### Set<T> ( ref T, T, string )
126+
#### VerifyPropertyName ( string )
125127

126-
`Set<T>(ref T, T, string)` has a renamed direct replacement, `SetProperty<T>(ref T, T, string)`.
128+
There is no direct replacement for the `VerifyPropertyName(string)` method and any code using this should be altered or removed.
127129

128130
```csharp
129131
// MvvmLight
130-
this.Set(ref this.myProperty, value, nameof(this.MyProperty));
132+
this.VerifyPropertyName(nameof(this.MyProperty));
131133

132134
// Toolkit.Mvvm
133-
this.SetProperty(ref this.myProperty, value, nameof(this.MyProperty));
135+
// No direct replacement, remove
134136
```
135137

136-
Note, string parameter is not required if the method is being called from the property's setter as it is inferred from the caller member name.
137-
138138
### ObservableObject Properties
139139

140140
#### PropertyChangedHandler

0 commit comments

Comments
 (0)