GuidAttribute Classe
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Fornisce un Guid esplicito quando un GUID automatico è indesiderato.
public ref class GuidAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Interface | System.AttributeTargets.Struct, Inherited=false)]
public sealed class GuidAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Interface | System.AttributeTargets.Struct, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class GuidAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Interface | System.AttributeTargets.Struct, Inherited=false)>]
type GuidAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Interface | System.AttributeTargets.Struct, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type GuidAttribute = class
inherit Attribute
Public NotInheritable Class GuidAttribute
Inherits Attribute
- Ereditarietà
- Attributi
Esempio
Nell'esempio seguente viene illustrato come applicare a GuidAttribute una classe esportata in COM con un GUID fisso.
using namespace System;
using namespace System::Runtime::InteropServices;
[GuidAttribute("9ED54F84-A89D-4fcd-A854-44251E925F09")]
public ref class SampleClass
{
// Insert class members here.
};
using System;
using System.Runtime.InteropServices;
[GuidAttribute("9ED54F84-A89D-4fcd-A854-44251E925F09")]
public class SampleClass
{
// Insert class members here.
}
Imports System.Runtime.InteropServices
<GuidAttribute("9ED54F84-A89D-4fcd-A854-44251E925F09")> _
Public Class SampleClass
' Insert class members here.
End Class
Commenti
È possibile applicare questo attributo ad assembly, interfacce, classi, enumerazioni, strutture o delegati, anche se l' Tlbimp.exe (utilità di importazione della libreria dei tipi) può essere applicata automaticamente quando importa una libreria dei tipi.
La stringa passata all'attributo deve essere in un formato che rappresenta un argomento costruttore accettabile per il tipo Guid. Per evitare conflitti con il tipo Guid, usare il nome GuidAttribute lungo in modo esplicito. Usare un GUID esplicito solo quando un tipo deve avere un GUID specifico. Se l'attributo viene omesso, viene assegnato automaticamente un GUID.
Costruttori
| Nome | Descrizione |
|---|---|
| GuidAttribute(String) |
Inizializza una nuova istanza della GuidAttribute classe con il GUID specificato. |
Proprietà
| Nome | Descrizione |
|---|---|
| TypeId |
Se implementato in una classe derivata, ottiene un identificatore univoco per questo Attribute. (Ereditato da Attribute) |
| Value |
Ottiene l'oggetto Guid della classe . |
Metodi
| Nome | Descrizione |
|---|---|
| Equals(Object) |
Restituisce un valore che indica se questa istanza è uguale a un oggetto specificato. (Ereditato da Attribute) |
| GetHashCode() |
Restituisce il codice hash per questa istanza. (Ereditato da Attribute) |
| GetType() |
Ottiene il Type dell'istanza corrente. (Ereditato da Object) |
| IsDefaultAttribute() |
Quando sottoposto a override in una classe derivata, indica se il valore di questa istanza è il valore predefinito per la classe derivata. (Ereditato da Attribute) |
| Match(Object) |
Quando sottoposto a override in una classe derivata, restituisce un valore che indica se questa istanza è uguale a un oggetto specificato. (Ereditato da Attribute) |
| MemberwiseClone() |
Crea una copia superficiale del Objectcorrente. (Ereditato da Object) |
| ToString() |
Restituisce una stringa che rappresenta l'oggetto corrente. (Ereditato da Object) |
Implementazioni dell'interfaccia esplicita
| Nome | Descrizione |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Esegue il mapping di un set di nomi a un set corrispondente di identificatori dispatch. (Ereditato da Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Recupera le informazioni sul tipo per un oggetto, che può essere utilizzato per ottenere le informazioni sul tipo per un'interfaccia. (Ereditato da Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
Recupera il numero di interfacce di informazioni sul tipo fornite da un oggetto (0 o 1). (Ereditato da Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Fornisce l'accesso alle proprietà e ai metodi esposti da un oggetto . (Ereditato da Attribute) |