-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
VBFixedArrayAttribute.vb
58 lines (47 loc) · 1.94 KB
/
VBFixedArrayAttribute.vb
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
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
Imports System
Namespace Global.Microsoft.VisualBasic
' -------------------------------------------------------------------
' VBFixedArray is used by the runtime to determine
' if the array should be written/read without the array descriptor.
' -------------------------------------------------------------------
<AttributeUsage(AttributeTargets.Field, Inherited:=False, AllowMultiple:=False)>
Public NotInheritable Class VBFixedArrayAttribute
Inherits Attribute
Friend FirstBound As Integer
Friend SecondBound As Integer
Public ReadOnly Property Bounds() As Integer()
Get
If Me.SecondBound = -1 Then
Return New Integer() {Me.FirstBound}
Else
Return New Integer() {Me.FirstBound, Me.SecondBound}
End If
End Get
End Property
Public ReadOnly Property Length() As Integer
Get
If Me.SecondBound = -1 Then
Return (Me.FirstBound + 1)
Else
Return (Me.FirstBound + 1) * (Me.SecondBound + 1)
End If
End Get
End Property
Public Sub New(ByVal UpperBound1 As Integer)
If UpperBound1 < 0 Then
Throw New ArgumentException(SR.Invalid_VBFixedArray)
End If
Me.FirstBound = UpperBound1
Me.SecondBound = -1
End Sub
Public Sub New(ByVal UpperBound1 As Integer, ByVal UpperBound2 As Integer)
If UpperBound1 < 0 OrElse UpperBound2 < 0 Then
Throw New ArgumentException(SR.Invalid_VBFixedArray)
End If
Me.FirstBound = UpperBound1
Me.SecondBound = UpperBound2
End Sub
End Class
End Namespace