Assembly.GetCustomAttributes Yöntem

Tanım

Bu derleme için özel öznitelikleri alır.

Aşırı Yüklemeler

GetCustomAttributes(Boolean)

Bu derleme için tüm özel öznitelikleri alır.

GetCustomAttributes(Type, Boolean)

Türe göre belirtilen şekilde bu derleme için özel öznitelikleri alır.

GetCustomAttributes(Boolean)

Kaynak:
Assembly.cs
Kaynak:
Assembly.cs
Kaynak:
Assembly.cs

Bu derleme için tüm özel öznitelikleri alır.

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()

Parametreler

inherit
Boolean

Türü nesneler Assemblyiçin bu bağımsız değişken yoksayılır.

Döndürülenler

Object[]

Bu derleme için özel öznitelikleri içeren bir dizi.

Uygulamalar

Açıklamalar

Bu yöntem, karşılık gelen ICustomAttributeProvider arabirim yöntemini uygular. Bu nedenle, inherit parametresi yoksayılsa bile belirtilmelidir.

Sahte öznitelik, öznitelik mevcut olduğunda ayarlanması gereken çekirdek meta verilerin bitlerini gösterir. Bir tür için meta verileri genişleten ve türle birlikte kaydedilen özel bir özniteliğin aksine, sahte öznitelik türün meta verilerini değiştirir ve sonra atılır. Sonuçta elde edilen bitlerin bazılarına mevcut yansıma API'leri kullanılarak erişilemez.

Aşağıdaki tabloda, yansımada kullanılabilen bitler için farklı sahte öznitelikler ve erişimciler özetlenir.

Pseudo-Attribute Meta Veri Bitleri Yansıma Erişimcisi
DllImportAttribute CorPInvokeMap

DLL adı
Sıradan yöntem/genel yöntem öznitelikleri için PInvokeMap erişimci yok.

DLL adı için erişimci yok.
GuidAttribute Gerçek bir özel öznitelik olarak depolanır. Gerçek bir özel öznitelik olarak erişilir.
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 Çeşitli bitler. Aksesuar yok.
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

Sınıf ambalajı.
Type.Attributes.LayoutSequential

Type.Attributes.ExplicitLayout

Type.Attributes.AnsiClass

Type.Attributes.UnicodeClass

Type.Attributes.AutoClass

Aksesuar yok.
FieldOffsetAttribute Alan uzaklığı. Aksesuar yok.
AssemblyLoadAttribute CorAssemblyFlags Erişimci veya numaralandırıcı yok.

Şunlara uygulanır

GetCustomAttributes(Type, Boolean)

Kaynak:
Assembly.cs
Kaynak:
Assembly.cs
Kaynak:
Assembly.cs

Türe göre belirtilen şekilde bu derleme için özel öznitelikleri alır.

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()

Parametreler

attributeType
Type

Özel özniteliklerin döndürülecek türü.

inherit
Boolean

Türü nesneler Assemblyiçin bu bağımsız değişken yoksayılır.

Döndürülenler

Object[]

tarafından attributeTypebelirtildiği gibi bu derleme için özel öznitelikleri içeren bir dizi.

Uygulamalar

Özel durumlar

attributeType, null değeridir.

attributeType bir çalışma zamanı türü değildir.

Açıklamalar

Bu yöntem, karşılık gelen ICustomAttributeProvider arabirim yöntemini uygular. Bu nedenle, inherit parametresi yoksayılsa bile belirtilmelidir.

Sahte öznitelik, öznitelik mevcut olduğunda ayarlanması gereken çekirdek meta verilerin bitlerini gösterir. Bir tür için meta verileri genişleten ve türle birlikte kaydedilen özel bir özniteliğin aksine, sahte öznitelik türün meta verilerini değiştirir ve sonra atılır. Sonuçta elde edilen bitlerin bazılarına mevcut yansıma API'leri kullanılarak erişilemez.

Aşağıdaki tabloda, yansımada kullanılabilen bitler için farklı sahte öznitelikler ve erişimciler özetlenir.

Pseudo-Attribute Meta Veri Bitleri Yansıma Erişimcisi
DllImportAttribute CorPInvokeMap

DLL adı
Sıradan yöntem/genel yöntem öznitelikleri için PInvokeMap erişimci yok.

DLL adı için erişimci yok.
GuidAttribute Gerçek bir özel öznitelik olarak depolanır. Gerçek bir özel öznitelik olarak erişilir.
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 Çeşitli bitler. Aksesuar yok.
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

Sınıf ambalajı.
Type.Attributes.LayoutSequential

Type.Attributes.ExplicitLayout

Type.Attributes.AnsiClass

Type.Attributes.UnicodeClass

Type.Attributes.AutoClass

Aksesuar yok.
FieldOffsetAttribute Alan uzaklığı. Aksesuar yok.
AssemblyLoadAttribute CorAssemblyFlags Erişimci veya numaralandırıcı yok.

Şunlara uygulanır