Lingua

BindAsAttribute Classe

Definizione

BindAsAttribute consente l'associazione di tipi NSNumber nativi, NSValue e NSString (per enumerazioni) in tipi gestiti più accurati.

[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
Ereditarietà
BindAsAttribute
Attributi

Commenti

Questo attributo viene in genere usato nei progetti di associazione per indicare un mapping speciale tra Objective-C e tipi gestiti:

// 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; }

In questo esempio, il rect parametro verrà associato come gestito CGRecte il valore restituito verrà associato come bool?.

Nelle definizioni di associazione di protocollo e modello questo attributo è supportato nei parametri, ma non nelle proprietà o nei valori restituiti.

Combinazioni supportate:
Tra NSNumber e bool, byte, sbyte, short, ushort, int, uint, long, ulong, nint, nuint, float, double, nfloat, any of the previous come tipo nullable o come matrice
Tra NSValue e NSRange, CGAffineTransform, CGPoint, CGRect, CGSize, CGVector, NSDirectionalEdgeInsets, CATransform3d, CLLocationCoordinate2d, CMTime, CMTimeMapping, CMTimeRange, MKCoordinateSpan, SCNMatrix4, SCNVector3, SCNVector4, UIEdgeInsets, UIOffset, uno dei precedenti come tipo nullable o come matrice.
Tra le enumerazioni supportate da NSString e l'enumerazione gestita corrispondente.

Costruttori

Nome Descrizione
BindAsAttribute(Type)

Inizializza un nuovo attributo BindAs con il tipo gestito specificato.

Campi

Nome Descrizione
OriginalType

Tipo di Objective-C.

Type

Tipo gestito.

Si applica a