-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEmployee.cs
81 lines (74 loc) · 2.32 KB
/
Employee.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using NMF.Collections.ObjectModel;
using NMF.Expressions;
namespace ConnectivityBenchmark
{
/// <summary>
/// Represents an employee
/// </summary>
class Employee : INotifyPropertyChanged
{
private string team;
private string name;
private ObservableList<Employee> knows = new ObservableList<Employee>();
/// <summary>
/// The team the employee is assigned to
/// </summary>
public string Team
{
get { return team; }
set { SetProperty(ref team, value); }
}
/// <summary>
/// The employees name
/// </summary>
public string Name
{
get { return name; }
set { SetProperty(ref name, value); }
}
/// <summary>
/// Gets a collection of known employees
/// </summary>
public IListExpression<Employee> Knows
{
get
{
return knows;
}
}
/// <summary>
/// Sets the given property
/// </summary>
/// <typeparam name="T">The property type</typeparam>
/// <param name="field">The backing field for the property</param>
/// <param name="value">The new value</param>
/// <param name="propertyName">The name of the property</param>
protected void SetProperty<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
{
if (!EqualityComparer<T>.Default.Equals(field, value))
{
field = value;
OnPropertyChanged(propertyName);
}
}
/// <summary>
/// Raises the PropertyChanged event for the given property
/// </summary>
/// <param name="propertyName"></param>
protected void OnPropertyChanged(string propertyName)
{
var handler = PropertyChanged;
if (handler != null)
{
handler.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
/// <summary>
/// Is fired whenever a property changes its value
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
}
}