Remove unnecessaray parameter of TizenDeviceInfo
[platform/upstream/xamarin-forms.git] / Xamarin.Forms.Pages / DataItem.cs
1 using System.ComponentModel;
2 using System.Runtime.CompilerServices;
3
4 namespace Xamarin.Forms.Pages
5 {
6         public class DataItem : IDataItem, INotifyPropertyChanged
7         {
8                 string _name;
9                 object _val;
10
11                 public DataItem()
12                 {
13                 }
14
15                 public DataItem(string name, object value)
16                 {
17                         _name = name;
18                         _val = value;
19                 }
20
21                 public string Name
22                 {
23                         get { return _name; }
24                         set
25                         {
26                                 if (_name == value)
27                                         return;
28                                 _name = value;
29                                 OnPropertyChanged();
30                         }
31                 }
32
33                 public object Value
34                 {
35                         get { return _val; }
36                         set
37                         {
38                                 if (_val == value)
39                                         return;
40                                 _val = value;
41                                 OnPropertyChanged();
42                         }
43                 }
44
45                 public event PropertyChangedEventHandler PropertyChanged;
46
47                 public override bool Equals(object obj)
48                 {
49                         if (ReferenceEquals(null, obj))
50                                 return false;
51                         if (ReferenceEquals(this, obj))
52                                 return true;
53                         if (obj.GetType() != GetType())
54                                 return false;
55                         return Equals((DataItem)obj);
56                 }
57
58                 public override int GetHashCode()
59                 {
60                         unchecked
61                         {
62                                 return ((_name?.GetHashCode() ?? 0) * 397) ^ (_val?.GetHashCode() ?? 0);
63                         }
64                 }
65
66                 public static bool operator ==(DataItem left, DataItem right)
67                 {
68                         return Equals(left, right);
69                 }
70
71                 public static bool operator !=(DataItem left, DataItem right)
72                 {
73                         return !Equals(left, right);
74                 }
75
76                 protected bool Equals(DataItem other)
77                 {
78                         return string.Equals(_name, other._name) && Equals(_val, other._val);
79                 }
80
81                 protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
82                 {
83                         PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
84                 }
85         }
86 }