-
Notifications
You must be signed in to change notification settings - Fork 2
/
NotifiableExpandoObject.cs
36 lines (31 loc) · 1.05 KB
/
NotifiableExpandoObject.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Net.DDP.Server
{
/// <summary>
/// Expando object that enables classes to subscribe to property changed notifications
/// Inherits from the INotifyPropertyChanged interface
/// </summary>
public abstract class NotifiableExpandoObject : UnsealedExpando, INotifyPropertyChanged
{
protected void OnPropertyChanged(string propertyName)
{
var eventHandler = PropertyChanged;
eventHandler?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public override bool TrySetMember(SetMemberBinder binder, object value)
{
var result = base.TrySetMember(binder, value);
OnPropertyChanged(binder.Name);
return result;
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
}