-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFieldValuePair.cs
57 lines (51 loc) · 1.87 KB
/
FieldValuePair.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
46
47
48
49
50
51
52
53
54
55
56
57
using System.Diagnostics;
namespace Dell.Premier.Web.Common.HttpClient
{
/// <summary>
/// <see cref="FieldValuePair" /> contains an immutable field value string pair.
/// </summary>
[DebuggerDisplay("{Field}: {Value}")]
public class FieldValuePair
{
private readonly string _field;
private readonly string _value;
private readonly int _hashCode;
/// <summary>Initializes a new instance of the <see cref="FieldValuePair" /> class.</summary>
/// <param name="field">The field name.</param>
/// <param name="value">The value.</param>
public FieldValuePair(string field, string value)
{
_field = field;
_value = value;
_hashCode = string.Format("{0}={1}", _field, _value).GetHashCode();
}
/// <summary>Gets the field name.</summary>
public string Field
{
get { return _field; }
}
/// <summary>Gets the value.</summary>
public string Value
{
get { return _value; }
}
/// <summary>Determines whether the specified object is equal to the current object.</summary>
/// <param name="obj">The object to compare with the current object.</param>
/// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
public override bool Equals(object obj)
{
var value = obj as FieldValuePair;
if (value == null)
{
return false;
}
return Field == value.Field && Value == value.Value;
}
/// <summary>Serves as a hash function for a particular type.</summary>
/// <returns>A hash code for the current object.</returns>
public override int GetHashCode()
{
return _hashCode;
}
}
}