ProtocolAttribute 類別

定義

屬性應用於代表 Objective-C 協定的介面。

[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface)]
public sealed class ProtocolAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface)>]
type ProtocolAttribute = class
    inherit Attribute
繼承
ProtocolAttribute
屬性

備註

Xamarin.iOS 會將所有帶有此屬性的介面匯出為協定至 Objective-C,而實作這些介面的類別在匯出至 Objective-C 時會被標記為實作對應協定。

// This will create an Objective-C protocol called 'IMyProtocol', with one required member ('requiredMethod')
[Protocol ("IMyProtocol")]
interface IMyProtocol
{
  [Export ("requiredMethod")]
  void RequiredMethod ();
}

// This will export the equivalent of "@interface MyClass : NSObject <IMyProtocol>" to Objective-C.
class MyClass : NSObject, IMyProtocol
{
  void RequiredMethod ()
  {
  }
}

建構函式

名稱 Description
ProtocolAttribute()

屬性應用於代表 Objective-C 協定的介面。

屬性

名稱 Description
BackwardsCompatibleCodeGeneration

此特性顯示綁定產生器是否能產生與該協定相容的向下相容程式碼。

特別是,如果這個屬性成立,綁定產生器會為可選成員產生擴充方法,並在 ProtocolMemberAttribute 協定介面上為所有協定成員產生屬性。

FormalSince

屬性應用於代表 Objective-C 協定的介面。

IsInformal

Objective-C 協議是否屬於非正式協議。

Name

通訊協定的名稱。

WrapperType

可用來包裝此協定實例的特定受管理型態。

適用於