Class VariantReferenceBindingHandle
A Variant that refers to a variable of another declared type: what an element of a param array is when the argument it was given is a variable
(MS-VBAL §5.3.1.5: the param array "behaves as if it was an array whose elements were 'byref' <positional-param> elements whose
declared types were Variant").
public sealed record VariantReferenceBindingHandle : IKnowledgeBinding, IBindingHandle, IEquatable<VariantReferenceBindingHandle>
- Inheritance
-
VariantReferenceBindingHandle
- Implements
- Inherited Members
- Extension Methods
Remarks
Read, it is a Variant holding the variable's value, as the type the variable is declared: TypeName(a(0)) of a Long is Long.
Written, it is the variable that is written, which holds a value of its declared type only: what is assigned to the element is let- or set-coerced to
DeclaredType before it is stored (DeclaredTypeOf(IBindingHandle?, VBType)), as an assignment to the variable would be - a String no Long
can hold is a type mismatch, and leaves the variable as it was.
A variable declared Variant holds a Variant already, which is read and written as it is: the handle says only that the element is a variable,
which a server is given by reference (VT_BYREF) when the param array is a late-bound member's arguments.
Constructors
VariantReferenceBindingHandle(IBindingHandle, VBType)
A Variant that refers to a variable of another declared type: what an element of a param array is when the argument it was given is a variable
(MS-VBAL §5.3.1.5: the param array "behaves as if it was an array whose elements were 'byref' <positional-param> elements whose
declared types were Variant").
public VariantReferenceBindingHandle(IBindingHandle Variable, VBType DeclaredType)
Parameters
VariableIBindingHandleThe cell of the variable the element refers to.
DeclaredTypeVBTypeThe declared type of the variable.
Remarks
Read, it is a Variant holding the variable's value, as the type the variable is declared: TypeName(a(0)) of a Long is Long.
Written, it is the variable that is written, which holds a value of its declared type only: what is assigned to the element is let- or set-coerced to
DeclaredType before it is stored (DeclaredTypeOf(IBindingHandle?, VBType)), as an assignment to the variable would be - a String no Long
can hold is a type mismatch, and leaves the variable as it was.
A variable declared Variant holds a Variant already, which is read and written as it is: the handle says only that the element is a variable,
which a server is given by reference (VT_BYREF) when the param array is a late-bound member's arguments.
Properties
BindingCapabilities
Indicates the valid members of this binding.
public BindingCapabilities BindingCapabilities { get; }
Property Value
DeclaredType
The declared type of the variable.
public VBType DeclaredType { get; init; }
Property Value
IsKnown
Whether the value held is known. When it is not, the value held is the one its type assumes.
public bool IsKnown { get; }
Property Value
Value
The bound runtime value, read without a resolver.
public IRuntimeValue Value { get; }
Property Value
Remarks
👉 A direct read for the common literal/value cases. Handles that resolve a value lazily or via a reference still expose GetValue(ISymbolResolver).
Exceptions
- NotSupportedException
The binding has no readable value.
Variable
The cell of the variable the element refers to.
public IBindingHandle Variable { get; init; }
Property Value
Methods
DeclaredTypeOf(IBindingHandle?, VBType)
The declared type a value assigned through cell is coerced to: the referenced variable's, for a VariantReferenceBindingHandle,
and itemType, the element type of the array, for any other cell.
public static VBType DeclaredTypeOf(IBindingHandle? cell, VBType itemType)
Parameters
cellIBindingHandleThe cell of an element, or null for an element that has none.
itemTypeVBTypeThe element type of the array the element is of.
Returns
Forget()
Makes the value held not known, keeping it as the value assumed in its place.
public void Forget()
GetValue(ISymbolResolver)
Gets the value associated to this handle, resolving through resolver when
the binding is not self-contained.
public IRuntimeValue GetValue(ISymbolResolver resolver)
Parameters
resolverISymbolResolver
Returns
Remarks
👉 Verify that the binding supports GetValue.
Exceptions
Invoke(ISymbolResolver, IRuntimeValue[])
Invokes the callable entity associated to this handle, and returns the runtime value it yields - an HRESULT (S_OK), for one that yields no value.
public IRuntimeValue Invoke(ISymbolResolver resolver, IRuntimeValue[] args)
Parameters
resolverISymbolResolverargsIRuntimeValue[]
Returns
Remarks
👉 Verify that the binding supports Invoke.
A handle to code that runs on a call stack does not push the frame itself: it hands the call to an IProcedureInvoker.
Exceptions
- NotSupportedException
The binding does not support Invoke.
- VBRuntimeErrorException
A run-time error was raised by the invoked entity and nothing handled it.
SetValue(ISymbolResolver, IRuntimeValue)
Sets the value associated to this handle.
public void SetValue(ISymbolResolver resolver, IRuntimeValue value)
Parameters
resolverISymbolResolvervalueIRuntimeValue
Remarks
👉 Verify that the binding supports SetValue.
Exceptions
Store(IRuntimeValue, bool)
Replaces the value held, and says whether the new value is known.
public void Store(IRuntimeValue value, bool isKnown)
Parameters
valueIRuntimeValueThe new value, or the value assumed in place of one that is not known.
isKnownboolWhether
valueis known.