1 |
#Region "Microsoft.VisualBasic::800cd9c14d926bd08a00832f76d8003f, Microsoft.VisualBasic.Core\Net\Protocol\Streams\Array.vb"
|
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 |
#End Region
|
58 |
|
59 |
Imports Microsoft.VisualBasic.Linq.Extensions
|
60 |
|
61 |
Namespace Net.Protocols.Streams.Array
|
62 |
|
63 |
Public Class [Long] : Inherits ValueArray(Of Long)
|
64 |
|
65 |
Sub New()
|
66 |
Call MyBase.New(AddressOf BitConverter.GetBytes, AddressOf __toInt64, Int64, Nothing)
|
67 |
End Sub
|
68 |
|
69 |
Sub New(rawStream As Byte())
|
70 |
Call MyBase.New(AddressOf BitConverter.GetBytes, AddressOf __toInt64, Int64, rawStream)
|
71 |
End Sub
|
72 |
|
73 |
Sub New(array As IEnumerable(Of Long))
|
74 |
Call Me.New
|
75 |
Values = array.ToArray
|
76 |
End Sub
|
77 |
|
78 |
Private Shared Function __toInt64(byts As Byte()) As Long
|
79 |
Return BitConverter.ToInt64(byts, Scan0)
|
80 |
End Function
|
81 |
End Class
|
82 |
|
83 |
Public Class [Integer] : Inherits ValueArray(Of Integer)
|
84 |
|
85 |
Sub New()
|
86 |
Call MyBase.New(AddressOf BitConverter.GetBytes, AddressOf __toInt32, Int32, Nothing)
|
87 |
End Sub
|
88 |
|
89 |
Sub New(rawStream As Byte())
|
90 |
Call MyBase.New(AddressOf BitConverter.GetBytes, AddressOf __toInt32, Int32, rawStream)
|
91 |
End Sub
|
92 |
|
93 |
Sub New(array As IEnumerable(Of Integer))
|
94 |
Call Me.New
|
95 |
Values = array.ToArray
|
96 |
End Sub
|
97 |
|
98 |
Private Shared Function __toInt32(byts As Byte()) As Integer
|
99 |
Return BitConverter.ToInt32(byts, Scan0)
|
100 |
End Function
|
101 |
End Class
|
102 |
|
103 |
Public Class [Double] : Inherits ValueArray(Of Double)
|
104 |
|
105 |
Sub New()
|
106 |
Call MyBase.New(AddressOf BitConverter.GetBytes, AddressOf __toFloat, DblFloat, Nothing)
|
107 |
End Sub
|
108 |
|
109 |
Sub New(array As IEnumerable(Of Double))
|
110 |
Call Me.New
|
111 |
Values = array.ToArray
|
112 |
End Sub
|
113 |
|
114 |
Sub New(rawStream As Byte())
|
115 |
Call MyBase.New(AddressOf BitConverter.GetBytes, AddressOf __toFloat, DblFloat, rawStream)
|
116 |
End Sub
|
117 |
|
118 |
Private Shared Function __toFloat(byts As Byte()) As Double
|
119 |
Return BitConverter.ToDouble(byts, Scan0)
|
120 |
End Function
|
121 |
End Class
|
122 |
|
123 |
Public Class [Boolean] : Inherits ValueArray(Of Boolean)
|
124 |
|
125 |
Sub New()
|
126 |
Call MyBase.New(AddressOf BitConverter.GetBytes, Nothing, 1, Nothing)
|
127 |
End Sub
|
128 |
|
129 |
Sub New(rawStream As Byte())
|
130 |
Call Me.New
|
131 |
|
132 |
If Not rawStream.IsNullOrEmpty Then
|
133 |
Me.Values = rawStream _
|
134 |
.Select(AddressOf __toBoolean) _
|
135 |
.ToArray
|
136 |
Else
|
137 |
Me.Values = New Boolean() {}
|
138 |
End If
|
139 |
End Sub
|
140 |
|
141 |
Sub New(array As IEnumerable(Of Boolean))
|
142 |
Call Me.New
|
143 |
Values = array.ToArray
|
144 |
End Sub
|
145 |
|
146 |
Private Shared Function __toBoolean(byt As Byte) As Boolean
|
147 |
If byt = 0 Then
|
148 |
Return False
|
149 |
Else
|
150 |
Return True
|
151 |
End If
|
152 |
End Function
|
153 |
End Class
|
154 |
End Namespace
|