Share via


MonoNativeFunctionWrapperAttribute Classe

Definição

Atributo a ser aplicado aos delegados para sinalizá-los como destinos que podem ser usados com GetDelegateForFunctionPointer(IntPtr, Type).

[System.AttributeUsage(System.AttributeTargets.Delegate)]
public sealed class MonoNativeFunctionWrapperAttribute : Attribute
type MonoNativeFunctionWrapperAttribute = class
    inherit Attribute
Herança
MonoNativeFunctionWrapperAttribute
Atributos

Comentários

Como o Xamarin.iOS é executado no modo totalmente compilado estaticamente, é necessário sinalizar métodos delegados que podem ser passados para o GetDelegateForFunctionPointer(IntPtr, Type) com esse atributo. Isso instrui o compilador AOT a gerar o código necessário para permitir que um ponteiro para uma função nativa produza um delegado gerenciado callable para o método .

[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);
}

Construtores

MonoNativeFunctionWrapperAttribute()

Construtor padrão.

Aplica-se a