ProtocolAttribute Classe
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Attribut appliqué aux interfaces qui représentent des protocoles 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
- Héritage
-
ProtocolAttribute
- Attributs
Remarques
Xamarin.iOS exportera toutes les interfaces avec cet attribut en tant que protocole vers Objective-C, et toutes les classes qui implémentent ces interfaces seront marquées comme implémentant le protocole correspondant lorsqu’elles sont exportées vers 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 ()
{
}
}
Constructeurs
| Nom | Description |
|---|---|
| ProtocolAttribute() |
Attribut appliqué aux interfaces qui représentent des protocoles Objective-C. |
Propriétés
| Nom | Description |
|---|---|
| BackwardsCompatibleCodeGeneration |
Cette propriété indique si le générateur de liaison génère du code rétrocompatible pour le protocole en question. En particulier, si cette propriété a la valeur true, le générateur de liaison génère des méthodes d’extension pour les membres et ProtocolMemberAttribute attributs facultatifs sur l’interface de protocole pour tous les membres du protocole. |
| FormalSince |
Attribut appliqué aux interfaces qui représentent des protocoles Objective-C. |
| IsInformal |
Indique si le protocole Objective-C est un protocole informel. |
| Name |
Nom du protocole. |
| WrapperType |
Type managé spécifique qui peut être utilisé pour encapsuler une instance de ce protocole. |