-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmailAddress.cs
More file actions
81 lines (71 loc) · 1.48 KB
/
EmailAddress.cs
File metadata and controls
81 lines (71 loc) · 1.48 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
using System;
using System.Collections.Generic;
using System.Text;
namespace AutomaticAnnouncements
{
/*
* Basic class for email addresses to help the email service
* Everything here should be self-explanatory
*/
public class EmailAddress
{
public string Name { get; set; }
public string Address { get; set; }
public EmailAddress() { }
public EmailAddress(string name, string adress) {
Name = name;
Address = adress;
}
public static bool operator ==(EmailAddress obj1, EmailAddress obj2)
{
if (ReferenceEquals(obj1, obj2))
{
return true;
}
if (obj1 is null)
{
return false;
}
if (obj2 is null)
{
return false;
}
return (obj1.Name == obj2.Name
&& obj1.Address == obj2.Address);
}
public static bool operator !=(EmailAddress obj1, EmailAddress obj2)
{
return !(obj1 == obj2);
}
public bool Equals(EmailAddress other)
{
if (other is null)
{
return false;
}
if (ReferenceEquals(this, other))
{
return true;
}
return Name.Equals(other.Name)
&& Address.Equals(other.Address);
}
public override bool Equals(object obj)
{
if (obj is null)
{
return false;
}
return ReferenceEquals(this, obj) ? true : obj.GetType() == GetType() && Equals((EmailAddress)obj);
}
public override int GetHashCode()
{
unchecked
{
int hashCode = Name.GetHashCode();
hashCode = (hashCode * 397) ^ Address.GetHashCode();
return hashCode;
}
}
}
}