forked from ical-org/ical.net
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequestStatus.cs
More file actions
78 lines (67 loc) · 2.18 KB
/
RequestStatus.cs
File metadata and controls
78 lines (67 loc) · 2.18 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
using System.IO;
using Ical.Net.Serialization.DataTypes;
namespace Ical.Net.DataTypes
{
/// <summary>
/// A class that represents the return status of an iCalendar request.
/// </summary>
public class RequestStatus : EncodableDataType
{
public string Description { get; set; }
public string ExtraData { get; set; }
public StatusCode StatusCode { get; set; }
public RequestStatus() {}
public RequestStatus(string value) : this()
{
var serializer = new RequestStatusSerializer();
CopyFrom(serializer.Deserialize(new StringReader(value)) as ICopyable);
}
public override void CopyFrom(ICopyable obj)
{
base.CopyFrom(obj);
if (!(obj is RequestStatus rs))
{
return;
}
if (rs.StatusCode != null)
{
StatusCode = rs.StatusCode;
}
Description = rs.Description;
rs.ExtraData = rs.ExtraData;
}
public override string ToString()
{
var serializer = new RequestStatusSerializer();
return serializer.SerializeToString(this);
}
protected bool Equals(RequestStatus other) => string.Equals(Description, other.Description) && string.Equals(ExtraData, other.ExtraData) &&
Equals(StatusCode, other.StatusCode);
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
if (obj.GetType() != GetType())
{
return false;
}
return Equals((RequestStatus) obj);
}
public override int GetHashCode()
{
unchecked
{
var hashCode = Description?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ (ExtraData?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (StatusCode?.GetHashCode() ?? 0);
return hashCode;
}
}
}
}