This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathThing.cs
More file actions
115 lines (98 loc) · 2.75 KB
/
Copy pathThing.cs
File metadata and controls
115 lines (98 loc) · 2.75 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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using GitHub.Collections;
using System;
using System.ComponentModel;
public class Thing : ICopyable<Thing>, IEquatable<Thing>, IComparable<Thing>, INotifyPropertyChanged
{
public Thing(int id, string title, DateTimeOffset date1, DateTimeOffset date2)
{
Number = id;
Title = title;
CreatedAt = date1;
UpdatedAt = date2;
}
public Thing(int id, string title, DateTimeOffset date)
{
Number = id;
Title = title;
CreatedAt = date;
UpdatedAt = date;
}
public Thing()
{
}
public void CopyFrom(Thing other)
{
Title = other.Title;
CreatedAt = other.CreatedAt;
UpdatedAt = other.UpdatedAt;
}
public bool Equals(Thing other)
{
if (ReferenceEquals(this, other))
return true;
return other != null && other.Number == Number;
}
public override bool Equals(object obj)
{
var other = obj as Thing;
if (other != null)
return Equals(other);
return base.Equals(obj);
}
public override int GetHashCode()
{
return Number;
}
public static bool operator >(Thing lhs, Thing rhs)
{
if (ReferenceEquals(lhs, rhs))
return false;
return lhs?.CompareTo(rhs) > 0;
}
public static bool operator <(Thing lhs, Thing rhs)
{
if (ReferenceEquals(lhs, rhs))
return false;
return (object)lhs == null || lhs.CompareTo(rhs) < 0;
}
public static bool operator ==(Thing lhs, Thing rhs)
{
return Equals(lhs, rhs) && ((object)lhs == null || lhs.CompareTo(rhs) == 0);
}
public static bool operator !=(Thing lhs, Thing rhs)
{
return !(lhs == rhs);
}
public int Number { get; set; }
string title;
public string Title
{
get { return title; }
set { title = value; OnPropertyChanged(nameof(Title)); }
}
DateTimeOffset createdAt;
public DateTimeOffset CreatedAt
{
get { return createdAt; }
set { createdAt = value; OnPropertyChanged(nameof(CreatedAt)); }
}
DateTimeOffset updatedAt;
public DateTimeOffset UpdatedAt
{
get { return updatedAt; }
set { updatedAt = value; OnPropertyChanged(nameof(UpdatedAt)); }
}
public event PropertyChangedEventHandler PropertyChanged;
void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public override string ToString()
{
return string.Format("id:{0} title:{1} created:{2:u} updated:{3:u}", Number, Title, CreatedAt, UpdatedAt);
}
public int CompareTo(Thing other)
{
return UpdatedAt.CompareTo(other.UpdatedAt);
}
}