Editar

Partilhar via


SpanMarshaller<T,TUnmanagedElement> Class

Definition

Important

This API is not CLS-compliant.

Supports marshalling a Span<T> from managed value to a contiguous native array of the unmanaged values of the elements.

generic <typename T, typename TUnmanagedElement>
 where TUnmanagedElement : value classpublic ref class SpanMarshaller abstract sealed
[System.CLSCompliant(false)]
[System.Runtime.InteropServices.Marshalling.ContiguousCollectionMarshaller]
[System.Runtime.InteropServices.Marshalling.CustomMarshaller(typeof(System.Span<>), System.Runtime.InteropServices.Marshalling.MarshalMode.Default, typeof(System.Runtime.InteropServices.Marshalling.SpanMarshaller<,>))]
[System.Runtime.InteropServices.Marshalling.CustomMarshaller(typeof(System.Span<>), System.Runtime.InteropServices.Marshalling.MarshalMode.ManagedToUnmanagedIn, typeof(System.Runtime.InteropServices.Marshalling.SpanMarshaller<,>+ManagedToUnmanagedIn))]
public static class SpanMarshaller<T,TUnmanagedElement> where TUnmanagedElement : struct
[<System.CLSCompliant(false)>]
[<System.Runtime.InteropServices.Marshalling.ContiguousCollectionMarshaller>]
[<System.Runtime.InteropServices.Marshalling.CustomMarshaller(typeof(System.Span<>), System.Runtime.InteropServices.Marshalling.MarshalMode.Default, typeof(System.Runtime.InteropServices.Marshalling.SpanMarshaller<,>))>]
[<System.Runtime.InteropServices.Marshalling.CustomMarshaller(typeof(System.Span<>), System.Runtime.InteropServices.Marshalling.MarshalMode.ManagedToUnmanagedIn, typeof(System.Runtime.InteropServices.Marshalling.SpanMarshaller<,>+ManagedToUnmanagedIn))>]
type SpanMarshaller<'T, 'UnmanagedElement (requires 'UnmanagedElement : struct)> = class
Public Class SpanMarshaller(Of T, TUnmanagedElement)

Type Parameters

T

The managed element type of the span.

TUnmanagedElement

The unmanaged type for the elements of the span.

Inheritance
SpanMarshaller<T,TUnmanagedElement>
Attributes

Remarks

A Span<T> marshalled with this marshaller will match the semantics of GetReference<T>(Span<T>). In particular, this marshaller will pass a non-null value for a zero-length span if the span was constructed with a non-null value.

Methods

AllocateContainerForManagedElements(TUnmanagedElement*, Int32)

Allocates space to store the managed elements.

AllocateContainerForUnmanagedElements(Span<T>, Int32)

Allocates the space to store the unmanaged elements.

Free(TUnmanagedElement*)

Frees the allocated unmanaged memory.

GetManagedValuesDestination(Span<T>)

Gets a span of the space where the managed collection elements should be stored.

GetManagedValuesSource(Span<T>)

Gets a span of the managed collection elements.

GetUnmanagedValuesDestination(TUnmanagedElement*, Int32)

Gets a span of the space where the unmanaged collection elements should be stored.

GetUnmanagedValuesSource(TUnmanagedElement*, Int32)

Gets a span of the native collection elements.

Applies to