Language

BindAsAttribute クラス

定義

BindAsAttribute を使用すると、ネイティブの NSNumber、NSValue、NSString (列挙型の場合) をより正確なマネージド型にバインドできます。

[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
継承
BindAsAttribute
属性

注釈

この属性は、通常、Objective-C 型とマネージド型の間の特別なマッピングを示すために、バインド プロジェクトで使用されます。

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

この例では、 rect パラメーターはマネージド CGRectとしてバインドされ、戻り値は bool?としてバインドされます。

プロトコルとモデルのバインド定義では、この属性はパラメーターではサポートされますが、プロパティや戻り値ではサポートされません。

サポートされる組み合わせ:
NSNumber と bool、byte、sbyte、short、ushort、int、uint、long、ulong、nint、nuint、float、double、nfloat の間で、null 許容型として、または配列として前のいずれか
NSValue と NSRange の間 CGAffineTransform、CGPoint、CGRect、CGSize、CGVector、NSDirectionalEdgeInsets、CATransform3d、CLLocationCoordinate2d、CMTime、CMTimeMapping、CMTimeRange、MKCoordinateSpan、SCNMatrix4、SCNVector3、SCNVector4、UIEdgeInsets、UIOffset、以前のいずれか null 許容型として、または配列として。
NSString でサポートされる列挙型と対応するマネージド列挙型の間。

コンストラクター

Name 説明
BindAsAttribute(Type)

指定したマネージド型を使用して、新しい BindAs 属性を初期化します。

フィールド

Name 説明
OriginalType

Objective-C 型。

Type

マネージド型。

適用対象