Class SafeArrayMarshaller
- Namespace
- CsCom.Runtime
- Assembly
- CsCom.Runtime.dll
Marshals arrays of up to three dimensions as SAFEARRAYs.
[CustomMarshaller(typeof(Array), MarshalMode.Default, typeof(SafeArrayMarshaller))]
public static class SafeArrayMarshaller
- Inheritance
-
SafeArrayMarshaller
- Inherited Members
Remarks
The variant type of the elements is derived from the element type of the array, as by SafeArrayMarshaller<T>,
so the arrays passed to COM methods must have the element type of the SAFEARRAY, e.g. string[,] for
SAFEARRAY(BSTR). Returned arrays are converted to zero-based arrays whose element type is determined by the variant
type of the SAFEARRAY; the elements of multidimensional arrays keep their indices.
Methods
ConvertToManaged(nint)
Converts a SAFEARRAY to an array.
public static Array? ConvertToManaged(nint unmanaged)
Parameters
unmanagednint
Returns
ConvertToManaged2D<T>(nint)
Converts a two-dimensional SAFEARRAY to a zero-based array of T, converting the elements
when the variant type of the SAFEARRAY does not match. Used by the marshallers generated for the parameters
whose rank is known.
public static T[,]? ConvertToManaged2D<T>(nint unmanaged)
Parameters
unmanagednint
Returns
- T[,]
Type Parameters
T
Exceptions
- SafeArrayRankMismatchException
The
SAFEARRAYdoes not have two dimensions.
ConvertToManaged3D<T>(nint)
Converts a three-dimensional SAFEARRAY to a zero-based array of T, converting the elements
when the variant type of the SAFEARRAY does not match. Used by the marshallers generated for the parameters
whose rank is known.
public static T[,,]? ConvertToManaged3D<T>(nint unmanaged)
Parameters
unmanagednint
Returns
- T[,,]
Type Parameters
T
Exceptions
- SafeArrayRankMismatchException
The
SAFEARRAYdoes not have three dimensions.
ConvertToUnmanaged(Array?)
Creates a SAFEARRAY from an array.
public static nint ConvertToUnmanaged(Array? managed)
Parameters
managedArray
Returns
Free(nint)
Destroys the SAFEARRAY.
public static void Free(nint unmanaged)
Parameters
unmanagednint