-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLogPacketAttribute.cs
87 lines (77 loc) · 2.1 KB
/
LogPacketAttribute.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System;
namespace PacketLogConverter
{
/// <summary>
/// Denotes a class as a packet
/// </summary>
[Serializable, AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class LogPacketAttribute : Attribute
{
private int m_packetCode;
private float m_version;
private ePacketDirection m_direction;
private string m_description;
public LogPacketAttribute(int packetCode, float version, ePacketDirection direction)
: this(packetCode, version, direction, null)
{
}
public LogPacketAttribute(int packetCode, float version, ePacketDirection direction, string packetDescription)
{
m_packetCode = packetCode;
m_version = version;
m_direction = direction;
m_description = packetDescription.ToLower();
}
public int Code
{
get { return m_packetCode; }
}
public float Version
{
get { return m_version; }
}
public ePacketDirection Direction
{
get { return m_direction; }
}
public string Description
{
get { return m_description; }
}
///<summary>
///Returns a value that indicates whether this instance is equal to a specified object.
///</summary>
///
///<returns>
///true if obj equals the type and value of this instance; otherwise, false.
///</returns>
///
///<param name="obj">An <see cref="T:System.Object"></see> to compare with this instance or null. </param><filterpriority>2</filterpriority>
public override bool Equals(object obj)
{
bool ret = false;
LogPacketAttribute attr = obj as LogPacketAttribute;
if (attr != null)
{
// Check all fields
ret = attr.m_direction == m_direction;
ret &= attr.m_packetCode == m_packetCode;
ret &= attr.m_version == m_version;
}
return ret;
}
///<summary>
///Returns the hash code for this instance.
///</summary>
///
///<returns>
///A 32-bit signed integer hash code.
///</returns>
///<filterpriority>2</filterpriority>
public override int GetHashCode()
{
int ret = (int) m_direction + m_packetCode + (int) m_version;
return ret;
}
}
}