BindAsAttribute Clase
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
BindAsAttribute permite enlazar tipos NSNumber, NSValue y NSString nativos (para enumeraciones) en tipos administrados más 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
- Herencia
-
BindAsAttribute
- Atributos
Comentarios
Este atributo se usa normalmente en proyectos de enlace para indicar una asignación especial entre Objective-C y tipos administrados:
// 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; }
En este ejemplo, el rect parámetro se enlazará como administrado CGRecty el valor devuelto se enlazará como bool?.
En las definiciones de enlace de protocolo y modelo, este atributo se admite en parámetros, pero no en propiedades ni valores devueltos.
| Combinaciones admitidas: |
|---|
| Entre NSNumber y bool, byte, sbyte, short, ushort, int, uint, long, ulong, nint, nuint, float, double, nfloat, cualquiera de los anteriores como un tipo que acepta valores NULL o como una matriz |
| Entre NSValue y NSRange, CGAffineTransform, CGPoint, CGRect, CGSize, CGVector, NSDirectionalEdgeInsets, CATransform3d, CLLocationCoordinate2d, CMTime, CMTimeMapping, CMTimeRange, MKCoordinateSpan, SCNMatrix4, SCNVector3, SCNVector4, UIEdgeInsets, UIOffset, cualquiera de los anteriores como un tipo que acepta valores NULL o como una matriz. |
| Entre las enumeraciones respaldadas por NSString y la enumeración administrada correspondiente. |
Constructores
| Nombre | Description |
|---|---|
| BindAsAttribute(Type) |
Inicializa un nuevo atributo BindAs con el tipo administrado especificado. |
Campos
| Nombre | Description |
|---|---|
| OriginalType |
Tipo de Objective-C. |
| Type |
Tipo administrado. |