-
Notifications
You must be signed in to change notification settings - Fork 9
/
BinaryPacket.cs
117 lines (92 loc) · 2.36 KB
/
BinaryPacket.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace GeoFramework.Gps
{
/// <summary>
/// Represents a base class for designing GPS packets which store binary data.
/// </summary>
public abstract class BinaryPacket : Packet, IList<byte>
{
private List<byte> _Data;
protected BinaryPacket()
: this(32)
{ }
protected BinaryPacket(int capacity)
{
_Data = new List<byte>(capacity);
}
protected BinaryPacket(IEnumerable<byte> bytes)
{
_Data = new List<byte>(bytes);
}
#region IList<byte> Members
public int IndexOf(byte item)
{
return _Data.IndexOf(item);
}
public void Insert(int index, byte item)
{
_Data.Insert(index, item);
}
public void RemoveAt(int index)
{
_Data.RemoveAt(index);
}
public byte this[int index]
{
get
{
return _Data[index];
}
set
{
_Data[index] = value;
}
}
#endregion
#region ICollection<byte> Members
public void Add(byte item)
{
_Data.Add(item);
}
public void Clear()
{
_Data.Clear();
}
public bool Contains(byte item)
{
return _Data.Contains(item);
}
public void CopyTo(byte[] array, int arrayIndex)
{
_Data.CopyTo(array, arrayIndex);
}
public int Count
{
get { return _Data.Count; }
}
public bool IsReadOnly
{
get { return false; }
}
public bool Remove(byte item)
{
return _Data.Remove(item);
}
#endregion
#region IEnumerable<byte> Members
public IEnumerator<byte> GetEnumerator()
{
return _Data.GetEnumerator();
}
#endregion
#region IEnumerable Members
IEnumerator IEnumerable.GetEnumerator()
{
return _Data.GetEnumerator();
}
#endregion
}
}