@@ -8,34 +8,104 @@ public class Address
8
8
private string country ;
9
9
private StateProvince stateProvince ;
10
10
11
- public string Street
11
+ public virtual string Street
12
12
{
13
13
get { return street ; }
14
14
set { street = value ; }
15
15
}
16
16
17
- public string City
17
+ public virtual string City
18
18
{
19
19
get { return city ; }
20
20
set { city = value ; }
21
21
}
22
22
23
- public string PostalCode
23
+ public virtual string PostalCode
24
24
{
25
25
get { return postalCode ; }
26
26
set { postalCode = value ; }
27
27
}
28
28
29
- public string Country
29
+ public virtual string Country
30
30
{
31
31
get { return country ; }
32
32
set { country = value ; }
33
33
}
34
34
35
- public StateProvince StateProvince
35
+ public virtual StateProvince StateProvince
36
36
{
37
37
get { return stateProvince ; }
38
38
set { stateProvince = value ; }
39
39
}
40
+
41
+ public override bool Equals ( object obj )
42
+ {
43
+ if ( ! ( obj is Address ) )
44
+ return false ;
45
+
46
+ var otherAddress = ( ( Address ) obj ) ;
47
+
48
+ if ( Street == null ^ otherAddress . Street == null )
49
+ {
50
+ return false ;
51
+ }
52
+
53
+ if ( Street != null && otherAddress . Street != null && otherAddress . Street != Street )
54
+ {
55
+ return false ;
56
+ }
57
+
58
+ if ( City == null ^ otherAddress . City == null )
59
+ {
60
+ return false ;
61
+ }
62
+
63
+ if ( City != null && otherAddress . City != null && otherAddress . City != City )
64
+ {
65
+ return false ;
66
+ }
67
+
68
+ if ( PostalCode == null ^ otherAddress . PostalCode == null )
69
+ {
70
+ return false ;
71
+ }
72
+
73
+ if ( PostalCode != null && otherAddress . PostalCode != null && otherAddress . PostalCode != PostalCode )
74
+ {
75
+ return false ;
76
+ }
77
+
78
+ if ( Country == null ^ otherAddress . Country == null )
79
+ {
80
+ return false ;
81
+ }
82
+
83
+ if ( Country != null && otherAddress . Country != null && otherAddress . Country != Country )
84
+ {
85
+ return false ;
86
+ }
87
+
88
+ if ( StateProvince == null ^ otherAddress . StateProvince == null )
89
+ {
90
+ return false ;
91
+ }
92
+
93
+ if ( StateProvince != null && otherAddress . StateProvince != null && ! otherAddress . StateProvince . Equals ( StateProvince ) )
94
+ {
95
+ return false ;
96
+ }
97
+
98
+ return true ;
99
+ }
100
+
101
+ public override int GetHashCode ( )
102
+ {
103
+ int result = street != null ? street . GetHashCode ( ) : 0 ;
104
+ result = 31 * result + ( city != null ? city . GetHashCode ( ) : 0 ) ;
105
+ result = 31 * result + ( postalCode != null ? postalCode . GetHashCode ( ) : 0 ) ;
106
+ result = 31 * result + ( country != null ? country . GetHashCode ( ) : 0 ) ;
107
+ result = 31 * result + ( stateProvince != null ? stateProvince . GetHashCode ( ) : 0 ) ;
108
+ return result ;
109
+ }
40
110
}
41
111
}
0 commit comments