-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeatherMessage.cs
45 lines (38 loc) · 1.29 KB
/
WeatherMessage.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
using System;
namespace WeatherNotifierService
{
public class WeatherMessage : IComparable<WeatherMessage>
{
public DateTime IssuedAt { get; set; }
public string MessageType { get; set; }
public string RegionCode { get; set; }
public string OfficeCode { get; set; }
public string IssuedAtGmt { get; set; }
public string UpdateCode { get; set; }
public bool IsDiscussion { get; set; }
public bool IsUpdate { get; set; }
public string MessageText { get; set; }
public string HeaderText { get; set; }
public string RawText { get; set; }
public WeatherMessage(string rawText)
{
RawText = rawText;
}
public int CompareTo(WeatherMessage other)
{
// descending sort by date (newest message first)
return -IssuedAt.CompareTo(other.IssuedAt);
}
public override bool Equals(object other)
{
if (other == null) return false;
var otherMsg = other as WeatherMessage;
if (otherMsg == null) throw new ArgumentException();
return IssuedAt == otherMsg.IssuedAt;
}
public override int GetHashCode()
{
return IssuedAt.GetHashCode();
}
}
}