Skip to content

Commit 2797b71

Browse files
committed
trim 'Type' in property setter
1 parent 0bf6e35 commit 2797b71

File tree

1 file changed

+62
-50
lines changed

1 file changed

+62
-50
lines changed

src/NHibernate.Test/TypedManyToOne/AddressId.cs

Lines changed: 62 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,66 @@
22

33
namespace NHibernate.Test.TypedManyToOne
44
{
5-
[Serializable]
6-
public class AddressId
7-
{
8-
public virtual String Type { get; set; }
9-
public virtual String Id { get; set; }
10-
private int? requestedHash;
11-
12-
public AddressId(String type, String id)
13-
{
14-
Id = id;
15-
Type = type;
16-
}
17-
18-
public AddressId() { }
19-
20-
public override bool Equals(object obj)
21-
{
22-
return Equals(obj as AddressId);
23-
}
24-
25-
public virtual bool Equals(AddressId other)
26-
{
27-
if (ReferenceEquals(null, other))
28-
{
29-
return false;
30-
}
31-
if (ReferenceEquals(this, other))
32-
{
33-
return true;
34-
}
35-
return other.Id == Id && Equals(other.Type, Type);
36-
}
37-
38-
public override int GetHashCode()
39-
{
40-
if (!requestedHash.HasValue)
41-
{
42-
unchecked
43-
{
44-
requestedHash = (Id.GetHashCode() * 397) ^ Type.GetHashCode();
45-
}
46-
}
47-
return requestedHash.Value;
48-
}
49-
50-
public override string ToString()
51-
{
52-
return Type + '#' + Id;
53-
}
54-
}
5+
[Serializable]
6+
public class AddressId
7+
{
8+
private string _type;
9+
private int? requestedHash;
10+
11+
public virtual String Type
12+
{
13+
get { return _type; }
14+
set
15+
{
16+
if (!string.IsNullOrWhiteSpace(value))
17+
_type = value.Trim();
18+
else
19+
_type = value;
20+
}
21+
}
22+
public virtual String Id { get; set; }
23+
24+
public AddressId(String type, String id)
25+
{
26+
Id = id;
27+
_type = type;
28+
}
29+
30+
public AddressId() { }
31+
32+
public override bool Equals(object obj)
33+
{
34+
return Equals(obj as AddressId);
35+
}
36+
37+
public virtual bool Equals(AddressId other)
38+
{
39+
if (ReferenceEquals(null, other))
40+
{
41+
return false;
42+
}
43+
if (ReferenceEquals(this, other))
44+
{
45+
return true;
46+
}
47+
return other.Id == Id && Equals(other.Type, Type);
48+
}
49+
50+
public override int GetHashCode()
51+
{
52+
if (!requestedHash.HasValue)
53+
{
54+
unchecked
55+
{
56+
requestedHash = (Id.GetHashCode() * 397) ^ Type.GetHashCode();
57+
}
58+
}
59+
return requestedHash.Value;
60+
}
61+
62+
public override string ToString()
63+
{
64+
return Type + '#' + Id;
65+
}
66+
}
5567
}

0 commit comments

Comments
 (0)