BindAsAttribute Classe
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
O BindAsAttribute permite ligar tipos nativos NSNumber, NSValue e NSString (para enums) em tipos geridos 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
Observações
Este atributo é tipicamente usado em projetos de ligação, para indicar um mapeamento especial entre Objective-C e tipos geridos:
// 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á limitado como um gerido CGRect, e o valor de retorno será limitado como bool?.
Em definições de ligação de protocolos e modelos, este atributo é suportado em parâmetros, mas não em propriedades ou valores de retorno.
| Combinações suportadas: |
|---|
| Entre NSNumber e bool, byte, sbyte, short, ushort, int, uint, long, ulong, nint, nuint, float, double, nfloat, qualquer um dos anteriores como tipo nullable, ou como array |
| Entre NSValue e NSRange, CGAffineTransform, CGPoint, CGRect, CGSize, CGVector, NSDirectionalEdgeInsets, CATransform3d, CLLocationCoordinate2d, CMTime, CMTimeRange, MKCoordinateSpan, SCNMatrix4, SCNVector3, SCNVector4, UIEdgeInsets, UIOffset, qualquer um dos anteriores como tipo anulável ou como array. |
| Entre enums suportados por NSString e o enum gerido correspondente. |
Construtores
| Nome | Descrição |
|---|---|
| BindAsAttribute(Type) |
Inicializa um novo atributo BindAs com o tipo gerido especificado. |
Campos
| Nome | Descrição |
|---|---|
| OriginalType |
Do tipo Objective-C. |
| Type |
Do tipo gerido. |