-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmailMessage.cs
More file actions
75 lines (64 loc) · 1.88 KB
/
EmailMessage.cs
File metadata and controls
75 lines (64 loc) · 1.88 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AutomaticAnnouncements
{
/*
* Class for email messages to help the email service
*/
public class EmailMessage
{
public EmailMessage()
{
ToAddresses = new List<EmailAddress>();
FromAddresses = new List<EmailAddress>();
}
public List<EmailAddress> ToAddresses { get; set; }
public List<EmailAddress> FromAddresses { get; set; }
public string Subject { get; set; }
public string Content { get; set; }
public static bool operator ==(EmailMessage obj1, EmailMessage obj2)
{
if (ReferenceEquals(obj1, obj2)) { return true; }
if (obj1 is null || obj2 is null) { return false; }
return obj1.ToAddresses.All(obj2.ToAddresses.Contains)
&& obj1.FromAddresses.All(obj2.FromAddresses.Contains)
&& obj1.Subject == obj2.Subject
&& obj1.Content == obj2.Content;
}
public static bool operator !=(EmailMessage obj1, EmailMessage obj2)
{
return !(obj1 == obj2);
}
public bool Equals(EmailMessage other)
{
if (other is null) { return false; }
if (ReferenceEquals(this, other)) { return true; }
return ToAddresses.All(other.ToAddresses.Contains)
&& FromAddresses.All(other.FromAddresses.Contains)
&& Subject == other.Subject
&& Content == other.Content;
}
public override bool Equals(object obj)
{
if (obj is null) { return false; }
return ReferenceEquals(this, obj) ? true : obj.GetType() == GetType() && Equals((EmailMessage)obj);
}
public override int GetHashCode()
{
unchecked
{
int hashCode = ToAddresses.GetHashCode();
hashCode = (hashCode * 397) ^ FromAddresses.GetHashCode();
hashCode = (hashCode * 397) ^ Subject.GetHashCode();
hashCode = (hashCode * 397) ^ Content.GetHashCode();
return hashCode;
}
}
public override string ToString()
{
return "Subject: " + Subject;
}
}
}