-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPeopleViewModel.cs
More file actions
50 lines (38 loc) · 1.1 KB
/
Copy pathPeopleViewModel.cs
File metadata and controls
50 lines (38 loc) · 1.1 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using PeopleViewer.Common;
using PersonDataReader.Service;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace PeopleViewer.Presentation;
public class PeopleViewModel : INotifyPropertyChanged
{
protected IPersonReader DataReader;
private IEnumerable<Person> _people = new List<Person>();
public IEnumerable<Person> People
{
get => _people;
set { _people = value; RaisePropertyChanged(); }
}
public PeopleViewModel(IPersonReader reader)
{
DataReader = reader;
}
public async Task RefreshPeople()
{
People = await DataReader.GetPeople();
}
public void ClearPeople()
{
People = new List<Person>();
}
public string DataReaderType
{
get { return DataReader.GetTypeName(); }
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler? PropertyChanged;
private void RaisePropertyChanged([CallerMemberName] string? propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}