Idioma

BindAsAttribute Classe

Definição

O BindAsAttribute permite associar tipos NSNumber nativos, NSValue e NSString (para enums) em tipos gerenciados mais precisos.

[System.AttributeUsage(System.AttributeTargets.Parameter | System.AttributeTargets.Property | System.AttributeTargets.ReturnValue, AllowMultiple=false)]
public class BindAsAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Parameter | System.AttributeTargets.Property | System.AttributeTargets.ReturnValue, AllowMultiple=false)>]
type BindAsAttribute = class
    inherit Attribute
Herança
BindAsAttribute
Atributos

Comentários

Esse atributo normalmente é usado em projetos de associação, para indicar um mapeamento especial entre Objective-C e tipos gerenciados:

// NSValue <-> CGRect (for the 'rect' parameter)
// NSNumber <-> bool? (for the return value)
[return: BindAs (typeof (bool?))]
[Export ("shouldDrawAt:")]
NSNumber ShouldDraw ([BindAs (typeof (CGRect))] NSValue rect);

// NSString <-> CAScroll
[BindAs (typeof (CAScroll []))]
[Export ("supportedScrollModes")]
NSString [] SupportedScrollModes { get; set; }

Neste exemplo, o rect parâmetro será associado como um gerenciado CGRecte o valor retornado será associado como bool?.

Em definições de associação de protocolo e modelo, esse atributo tem suporte em parâmetros, mas não em propriedades ou valores retornados.

Combinações com suporte:
Entre NSNumber e bool, byte, sbyte, short, ushort, int, uint, long, ulong, nint, nuint, float, double, nfloat, qualquer um dos anteriores como um tipo anulável ou como uma matriz
Entre NSValue e NSRange, CGAffineTransform, CGPoint, CGRect, CGSize, CGVector, NSDirectionalEdgeInsets, CATransform3d, CLLocationCoordinate2d, CMTime, CMTimeMapping, CMTimeRange, MKCoordinateSpan, SCNMatrix4, SCNVector3, SCNVector4, UIEdgeInsets, UIOffset, qualquer um dos anteriores como um tipo anulável ou como uma matriz.
Entre enumerações apoiadas por NSString e a enumeração gerenciada correspondente.

Construtores

Nome Description
BindAsAttribute(Type)

Inicializa um novo atributo BindAs com o tipo gerenciado especificado.

Campos

Nome Description
OriginalType

O tipo Objective-C.

Type

O tipo gerenciado.

Aplica-se a