Metodo AttributeTable.GetCustomAttributes (Type)
Restituisce un'enumerazione di tutti gli attributi forniti per il tipo specificato.
Spazio dei nomi: Microsoft.Windows.Design.Metadata
Assembly: Microsoft.Windows.Design.Extensibility (in Microsoft.Windows.Design.Extensibility.dll)
Sintassi
'Dichiarazione
Public Function GetCustomAttributes ( _
type As Type _
) As IEnumerable
public IEnumerable GetCustomAttributes(
Type type
)
public:
IEnumerable^ GetCustomAttributes(
Type^ type
)
member GetCustomAttributes :
type:Type -> IEnumerable
public function GetCustomAttributes(
type : Type
) : IEnumerable
Parametri
- type
Tipo: System.Type
Tipo per cui ottenere attributi a livello di classe.
Valore restituito
Tipo: System.Collections.IEnumerable
Enumerazione di attributi.
Eccezioni
Eccezione | Condizione |
---|---|
ArgumentNullException | type è nullriferimento null (Nothing in Visual Basic). |
Note
Questo metodo non restituisce mai l'enumerazione nullriferimento null (Nothing in Visual Basic).
Esempi
Nell'esempio di codice seguente viene illustrato come utilizzare il metodo GetCustomAttributes per ottenere attributi personalizzati per un tipo. Questo esempio di codice fa parte di un esempio più completo fornito per la classe AttributeTable.
Dim attrs0 As IEnumerable = attributes.GetCustomAttributes(GetType(Button))
IEnumerable attrs0 = attributes.GetCustomAttributes(typeof(Button));
Sicurezza di .NET Framework
- Attendibilità totale per il chiamante immediato. Impossibile utilizzare questo membro in codice parzialmente attendibile. Per ulteriori informazioni, vedere Utilizzo di librerie da codice parzialmente attendibile.