markus / ConvertService / ServiceBase / Markus.Service.StationController / Base / Notification.cs @ 53c9637d
이력 | 보기 | 이력해설 | 다운로드 (1.07 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.ComponentModel; |
4 |
using System.Linq; |
5 |
using System.Linq.Expressions; |
6 |
using System.Text; |
7 |
using System.Threading.Tasks; |
8 |
|
9 |
namespace Markus.Service.StationController.Base |
10 |
{ |
11 |
public class NotifyExpectation : INotifyPropertyChanged |
12 |
{ |
13 |
public event PropertyChangedEventHandler PropertyChanged; |
14 |
protected virtual void OnPropertyChanged(Expression<Func<object>> propertyExpression) |
15 |
{ |
16 |
PropertyChangedEventHandler handler = PropertyChanged; |
17 |
if (handler != null) handler(this, new PropertyChangedEventArgs(GetPropertyName(propertyExpression))); |
18 |
} |
19 |
|
20 |
private string GetPropertyName(Expression<Func<object>> propertyExpression) |
21 |
{ |
22 |
var unaryExpression = propertyExpression.Body as UnaryExpression; |
23 |
var memberExpression = unaryExpression == null ? (MemberExpression)propertyExpression.Body : (MemberExpression)unaryExpression.Operand; |
24 |
var propertyName = memberExpression.Member.Name; |
25 |
return propertyName; |
26 |
} |
27 |
} |
28 |
} |