Class VBArrayValue
A VBTypedValue representing a runtime value of the VBArrayType data type.
public abstract record VBArrayValue : VBTypedValue, IEquatable<VBTypedValue>, IEquatable<VBArrayValue>
- Inheritance
-
VBArrayValue
- Implements
- Derived
- Inherited Members
Remarks
👉 The element store is a single flat block of IBindingHandle cells addressed in
column-major order (the first subscript varies fastest, as an OLE SAFEARRAY).
Bounds live in Dimensions as metadata (LBound/UBound/rank); the cells
are mutable storage. An uninitialized array (Dim a()) has no dimensions and no cells.
Constructors
VBArrayValue(IBindingHandle, (int lBound, int uBound)[], VBType)
Creates an array value bound to handle. The array's own binding is a
storage concern distinct from the element cells; it is currently inert (see the
session-storage follow-up).
protected VBArrayValue(IBindingHandle handle, (int lBound, int uBound)[] dimensions, VBType itemType)
Parameters
VBArrayValue(VBArrayValue)
protected VBArrayValue(VBArrayValue original)
Parameters
originalVBArrayValue
VBArrayValue((int lBound, int uBound)[], VBType)
Creates an array value with the given dimension bounds and element type.
protected VBArrayValue((int lBound, int uBound)[] dimensions, VBType itemType)
Parameters
dimensions(int lBound, int uBound)[]The lower and upper bound of each dimension, outermost first.
itemTypeVBTypeThe element type. Use VBVariantType when unspecified.
Properties
Dimensions
The bounds of each dimension (outermost first). Empty for an uninitialized array.
public ImmutableArray<VBArrayValue.VBArrayDimension> Dimensions { get; init; }
Property Value
IsInitialized
true if this array has at least one dimension.
public bool IsInitialized { get; }
Property Value
this[int[]]
Gets the element at the given subscripts, or null when any subscript is out of bounds
(semantics raise SubscriptOutOfRange in that case) or the subscript count does not match
the array rank.
public VBTypedValue? this[params int[] subscripts] { get; }
Parameters
subscriptsint[]
Property Value
ItemType
The declared VBType of the elements in this array.
public VBType ItemType { get; init; }
Property Value
Length
The total number of elements across every dimension.
public int Length { get; }
Property Value
Rank
The number of dimensions of this array. 0 for an uninitialized array.
public int Rank { get; }
Property Value
Size
The allocated size (in bytes) of this value.
public override int Size { get; }
Property Value
Methods
TryAllocateIn(ISessionStorage, out VBArrayValue?)
Reserves storage sized for this array's own slot through storage, and returns
a copy of this value bound to the resulting address. This is the array variable's
identity, distinct from its element cells (which remain the same managed storage): a real
address is what lets ReDim, Erase, and array-identity comparisons have something
to point at, matching how a SAFEARRAY variable's own slot is a pointer, never the array's
contents.
public bool TryAllocateIn(ISessionStorage storage, out VBArrayValue? allocated)
Parameters
storageISessionStorageallocatedVBArrayValue
Returns
- bool
falseif the underlying memory space is exhausted.
TrySetElement(IBindingHandle, params int[])
Rebinds the element at the given subscripts to value. Mutates the cell in
place — array element storage is mutable. Returns false when the subscripts are out of
bounds or their count does not match the array rank.
public bool TrySetElement(IBindingHandle value, params int[] subscripts)
Parameters
valueIBindingHandlesubscriptsint[]