blob: 62af919c13edb18abe2ba4a08e3c6ccf1a96e679 (
plain)
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
82
83
84
85
86
|
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace Xamarin.Forms.Pages
{
public class DataItem : IDataItem, INotifyPropertyChanged
{
string _name;
object _val;
public DataItem()
{
}
public DataItem(string name, object value)
{
_name = name;
_val = value;
}
public string Name
{
get { return _name; }
set
{
if (_name == value)
return;
_name = value;
OnPropertyChanged();
}
}
public object Value
{
get { return _val; }
set
{
if (_val == value)
return;
_val = value;
OnPropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
return false;
if (ReferenceEquals(this, obj))
return true;
if (obj.GetType() != GetType())
return false;
return Equals((DataItem)obj);
}
public override int GetHashCode()
{
unchecked
{
return ((_name?.GetHashCode() ?? 0) * 397) ^ (_val?.GetHashCode() ?? 0);
}
}
public static bool operator ==(DataItem left, DataItem right)
{
return Equals(left, right);
}
public static bool operator !=(DataItem left, DataItem right)
{
return !Equals(left, right);
}
protected bool Equals(DataItem other)
{
return string.Equals(_name, other._name) && Equals(_val, other._val);
}
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
|