hytos / ID2.Manager / ID2.Manager.Data / NotifyPropertyChange.cs @ d8bd4799
이력 | 보기 | 이력해설 | 다운로드 (974 Bytes)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.ComponentModel; |
4 |
using System.Linq; |
5 |
using System.Runtime.CompilerServices; |
6 |
using System.Text; |
7 |
using System.Threading.Tasks; |
8 |
|
9 |
namespace ID2.Manager.Data |
10 |
{ |
11 |
public class NotifyPropertyChange : INotifyPropertyChanged |
12 |
{ |
13 |
public bool SuspendUpdate; |
14 |
|
15 |
public event PropertyChangedEventHandler PropertyChanged; |
16 |
|
17 |
protected void RaisePropertyChanged(string propertyName) |
18 |
{ |
19 |
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
20 |
} |
21 |
|
22 |
protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null) |
23 |
{ |
24 |
if (EqualityComparer<T>.Default.Equals(storage, value)) |
25 |
return false; |
26 |
|
27 |
storage = value; |
28 |
|
29 |
if (!SuspendUpdate) |
30 |
{ |
31 |
RaisePropertyChanged(propertyName); |
32 |
} |
33 |
|
34 |
return true; |
35 |
} |
36 |
} |
37 |
} |