MonoNativeFunctionWrapperAttribute Classe

Definizione

Attributo da applicare ai delegati per contrassegnarli come destinazioni che possono essere usati con GetDelegateForFunctionPointer(IntPtr, Type).

[System.AttributeUsage(System.AttributeTargets.Delegate)]
public sealed class MonoNativeFunctionWrapperAttribute : Attribute
type MonoNativeFunctionWrapperAttribute = class
    inherit Attribute
Ereditarietà
MonoNativeFunctionWrapperAttribute
Attributi

Commenti

Poiché Xamarin.iOS viene eseguito in modalità completamente compilata in modo statico, è necessario contrassegnare i metodi delegati che potrebbero essere passati a GetDelegateForFunctionPointer(IntPtr, Type) con questo attributo. In questo modo viene indicato al compilatore AOT di generare il codice necessario per consentire a un puntatore a una funzione nativa di produrre un delegato gestito chiamabile per il metodo .

[MonoNativeFunctionWrapper]
delegate void SomeDelegate (int a, int b);

// 
// the ptrToFunc points to an unmanaged C function with the signature (int a, int b)
void Callback (IntPtr ptrToFunc)
{
	var del = (SomeDelegate) Marshal.GetDelegateForFunctionPointer (ptrToFunc, typeof (SomeDelegate));

	// invoke it
	del (1, 2);
}

Costruttori

MonoNativeFunctionWrapperAttribute()

Costruttore predefinito.

Si applica a