Assembly.GetCustomAttributes Metoda

Definicja

Pobiera atrybuty niestandardowe dla tego zestawu.

Przeciążenia

GetCustomAttributes(Boolean)

Pobiera wszystkie atrybuty niestandardowe dla tego zestawu.

GetCustomAttributes(Type, Boolean)

Pobiera atrybuty niestandardowe dla tego zestawu zgodnie z typem.

GetCustomAttributes(Boolean)

Źródło:
Assembly.cs
Źródło:
Assembly.cs
Źródło:
Assembly.cs

Pobiera wszystkie atrybuty niestandardowe dla tego zestawu.

public:
 virtual cli::array <System::Object ^> ^ GetCustomAttributes(bool inherit);
public virtual object[] GetCustomAttributes (bool inherit);
abstract member GetCustomAttributes : bool -> obj[]
override this.GetCustomAttributes : bool -> obj[]
Public Overridable Function GetCustomAttributes (inherit As Boolean) As Object()

Parametry

inherit
Boolean

Ten argument jest ignorowany dla obiektów typu Assembly.

Zwraca

Object[]

Tablica zawierająca atrybuty niestandardowe dla tego zestawu.

Implementuje

Uwagi

Ta metoda implementuje odpowiednią ICustomAttributeProvider metodę interfejsu. W związku z inherit tym należy określić parametr, mimo że jest on ignorowany.

Pseudo-atrybut wskazuje bity podstawowych metadanych, które należy ustawić, gdy atrybut jest obecny. W przeciwieństwie do atrybutu niestandardowego, który rozszerza metadane dla typu i jest zapisywany wraz z typem, pseudo-atrybut modyfikuje metadane dla typu, a następnie jest odrzucany. Do niektórych bitów wynikowych nie można uzyskać dostępu przy użyciu istniejących interfejsów API odbicia.

W poniższej tabeli podsumowano różne pseudo-atrybuty i metody dostępu dla bitów, które są dostępne w odbiciu.

Pseudo-Attribute Bity metadanych Akcesorium odbicia
DllImportAttribute CorPInvokeMap

Nazwa biblioteki DLL
Brak metody dostępu do PInvokeMap zwykłych atrybutów metody/metody globalnej.

Brak dostępu do nazwy biblioteki DLL.
GuidAttribute Przechowywane jako rzeczywisty atrybut niestandardowy. Uzyskiwany dostęp jako rzeczywisty atrybut niestandardowy.
ComImportAttribute CorTypeAttr.tdImport Type.Attributes.Import
SerializableAttribute CorTypeAttr.tdSerializable Type.Attributes.Serializable
NonSerializedAttribute CorFieldAttr.fdNotSerialized FieldInfo.Attributes.NotSerialized
MethodImplAttribute CorMethodImpl MethodInfo.GetMethodImplementationFlags()

ConstructorInfo.GetMethodImplementationFlags()
MarshalAsAttribute Różne bity. Brak akcesora.
PreserveSigAttribute CorMethodImpl.miOLE MethodInfo.GetMethodImplementationFlags().OLE

ConstructorInfo.GetMethodImplementationFlags().OLE
InAttribute CorParamAttr.pdIn ParameterInfo.Attributes.In
OutAttribute CorParamAttr.pdOut ParameterInfo.Attributes.Out
StructLayoutAttribute CorTypeAttr.tdLayoutSequential

CorTypeAttr.tdExplicitLayout

CorTypeAttr.tdAnsiClass

CorTypeAttr.tdUnicodeClass

CorTypeAttr.tdAutoClass

Pakowanie klas.
Type.Attributes.LayoutSequential

Type.Attributes.ExplicitLayout

Type.Attributes.AnsiClass

Type.Attributes.UnicodeClass

Type.Attributes.AutoClass

Brak akcesora.
FieldOffsetAttribute Przesunięcie pola. Brak akcesora.
AssemblyLoadAttribute CorAssemblyFlags Brak metody dostępu ani modułu wyliczającego.

Dotyczy

GetCustomAttributes(Type, Boolean)

Źródło:
Assembly.cs
Źródło:
Assembly.cs
Źródło:
Assembly.cs

Pobiera atrybuty niestandardowe dla tego zestawu zgodnie z typem.

public:
 virtual cli::array <System::Object ^> ^ GetCustomAttributes(Type ^ attributeType, bool inherit);
public virtual object[] GetCustomAttributes (Type attributeType, bool inherit);
abstract member GetCustomAttributes : Type * bool -> obj[]
override this.GetCustomAttributes : Type * bool -> obj[]
Public Overridable Function GetCustomAttributes (attributeType As Type, inherit As Boolean) As Object()

Parametry

attributeType
Type

Typ, dla którego mają być zwracane atrybuty niestandardowe.

inherit
Boolean

Ten argument jest ignorowany dla obiektów typu Assembly.

Zwraca

Object[]

Tablica zawierająca atrybuty niestandardowe dla tego zestawu określone przez attributeType.

Implementuje

Wyjątki

attributeType to null.

attributeType nie jest typem środowiska uruchomieniowego.

Uwagi

Ta metoda implementuje odpowiednią ICustomAttributeProvider metodę interfejsu. W związku z inherit tym należy określić parametr, mimo że jest on ignorowany.

Pseudo-atrybut wskazuje bity podstawowych metadanych, które należy ustawić, gdy atrybut jest obecny. W przeciwieństwie do atrybutu niestandardowego, który rozszerza metadane dla typu i jest zapisywany wraz z typem, pseudo-atrybut modyfikuje metadane dla typu, a następnie jest odrzucany. Do niektórych bitów wynikowych nie można uzyskać dostępu przy użyciu istniejących interfejsów API odbicia.

W poniższej tabeli podsumowano różne pseudo-atrybuty i metody dostępu dla bitów, które są dostępne w odbiciu.

Pseudo-Attribute Bity metadanych Akcesorium odbicia
DllImportAttribute CorPInvokeMap

Nazwa biblioteki DLL
Brak metody dostępu do PInvokeMap zwykłych atrybutów metody/metody globalnej.

Brak dostępu do nazwy biblioteki DLL.
GuidAttribute Przechowywane jako rzeczywisty atrybut niestandardowy. Uzyskiwany dostęp jako rzeczywisty atrybut niestandardowy.
ComImportAttribute CorTypeAttr.tdImport Type.Attributes.Import
SerializableAttribute CorTypeAttr.tdSerializable Type.Attributes.Serializable
NonSerializedAttribute CorFieldAttr.fdNotSerialized FieldInfo.Attributes.NotSerialized
MethodImplAttribute CorMethodImpl MethodInfo.GetMethodImplementationFlags()

ConstructorInfo.GetMethodImplementationFlags()
MarshalAsAttribute Różne bity. Brak akcesora.
PreserveSigAttribute CorMethodImpl.miOLE MethodInfo.GetMethodImplementationFlags().OLE

ConstructorInfo.GetMethodImplementationFlags().OLE
InAttribute CorParamAttr.pdIn ParameterInfo.Attributes.In
OutAttribute CorParamAttr.pdOut ParameterInfo.Attributes.Out
StructLayoutAttribute CorTypeAttr.tdLayoutSequential

CorTypeAttr.tdExplicitLayout

CorTypeAttr.tdAnsiClass

CorTypeAttr.tdUnicodeClass

CorTypeAttr.tdAutoClass

Pakowanie klas.
Type.Attributes.LayoutSequential

Type.Attributes.ExplicitLayout

Type.Attributes.AnsiClass

Type.Attributes.UnicodeClass

Type.Attributes.AutoClass

Brak akcesora.
FieldOffsetAttribute Przesunięcie pola. Brak akcesora.
AssemblyLoadAttribute CorAssemblyFlags Brak metody dostępu ani modułu wyliczającego.

Dotyczy