Assembly.GetCustomAttributes メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
このアセンブリのカスタム属性を取得します。
オーバーロード
| 名前 | 説明 |
|---|---|
| GetCustomAttributes(Boolean) |
このアセンブリのすべてのカスタム属性を取得します。 |
| GetCustomAttributes(Type, Boolean) |
型を指定して、このアセンブリのカスタム属性を取得します。 |
GetCustomAttributes(Boolean)
- ソース:
- Assembly.cs
- ソース:
- Assembly.cs
- ソース:
- Assembly.cs
- ソース:
- Assembly.cs
このアセンブリのすべてのカスタム属性を取得します。
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()
パラメーター
戻り値
このアセンブリのカスタム属性を格納する配列。
実装
注釈
このメソッドは、対応する ICustomAttributeProvider インターフェイス メソッドを実装します。 したがって、パラメーターは inherit 無視されても指定する必要があります。
擬似属性は、属性が存在するときに設定する必要があるコア メタデータのビットを示します。 型のメタデータを拡張し、型と共に保存されるカスタム属性とは異なり、擬似属性は型のメタデータを変更してから破棄されます。 結果として得られる一部のビットには、既存のリフレクション API を使用してアクセスできません。
次の表は、リフレクションで使用できるビットのさまざまな擬似属性とアクセサーをまとめたものです。
| Pseudo-Attribute | メタデータ ビット | リフレクション アクセサー |
|---|---|---|
| DllImportAttribute | CorPInvokeMapDLL 名 |
通常の PInvokeMap メソッド/グローバル メソッド属性のアクセサーはありません。DLL 名のアクセサーはありません。 |
| GuidAttribute | 実際のカスタム属性として格納されます。 | 実際のカスタム属性としてアクセスされます。 |
| 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 | さまざまなビット。 | アクセサーなし。 |
| PreserveSigAttribute | CorMethodImpl.miOLE |
MethodInfo.GetMethodImplementationFlags().OLEConstructorInfo.GetMethodImplementationFlags().OLE |
| InAttribute | CorParamAttr.pdIn |
ParameterInfo.Attributes.In |
| OutAttribute | CorParamAttr.pdOut |
ParameterInfo.Attributes.Out |
| StructLayoutAttribute | CorTypeAttr.tdLayoutSequentialCorTypeAttr.tdExplicitLayoutCorTypeAttr.tdAnsiClassCorTypeAttr.tdUnicodeClassCorTypeAttr.tdAutoClassクラスパッキング。 |
Type.Attributes.LayoutSequentialType.Attributes.ExplicitLayoutType.Attributes.AnsiClassType.Attributes.UnicodeClassType.Attributes.AutoClassアクセサーなし。 |
| FieldOffsetAttribute | フィールド オフセット。 | アクセサーなし。 |
AssemblyLoadAttribute |
CorAssemblyFlags |
アクセサーまたは列挙子はありません。 |
適用対象
GetCustomAttributes(Type, Boolean)
- ソース:
- Assembly.cs
- ソース:
- Assembly.cs
- ソース:
- Assembly.cs
- ソース:
- Assembly.cs
型を指定して、このアセンブリのカスタム属性を取得します。
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()
パラメーター
- attributeType
- Type
カスタム属性を返す対象の型。
戻り値
このアセンブリの、attributeType で指定されたカスタム属性を格納している配列。
実装
例外
attributeType が nullです。
attributeType はランタイム型ではありません。
注釈
このメソッドは、対応する ICustomAttributeProvider インターフェイス メソッドを実装します。 したがって、パラメーターは inherit 無視されても指定する必要があります。
擬似属性は、属性が存在するときに設定する必要があるコア メタデータのビットを示します。 型のメタデータを拡張し、型と共に保存されるカスタム属性とは異なり、擬似属性は型のメタデータを変更してから破棄されます。 結果として得られる一部のビットには、既存のリフレクション API を使用してアクセスできません。
次の表は、リフレクションで使用できるビットのさまざまな擬似属性とアクセサーをまとめたものです。
| Pseudo-Attribute | メタデータ ビット | リフレクション アクセサー |
|---|---|---|
| DllImportAttribute | CorPInvokeMapDLL 名 |
通常の PInvokeMap メソッド/グローバル メソッド属性のアクセサーはありません。DLL 名のアクセサーはありません。 |
| GuidAttribute | 実際のカスタム属性として格納されます。 | 実際のカスタム属性としてアクセスされます。 |
| 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 | さまざまなビット。 | アクセサーなし。 |
| PreserveSigAttribute | CorMethodImpl.miOLE |
MethodInfo.GetMethodImplementationFlags().OLEConstructorInfo.GetMethodImplementationFlags().OLE |
| InAttribute | CorParamAttr.pdIn |
ParameterInfo.Attributes.In |
| OutAttribute | CorParamAttr.pdOut |
ParameterInfo.Attributes.Out |
| StructLayoutAttribute | CorTypeAttr.tdLayoutSequentialCorTypeAttr.tdExplicitLayoutCorTypeAttr.tdAnsiClassCorTypeAttr.tdUnicodeClassCorTypeAttr.tdAutoClassクラスパッキング。 |
Type.Attributes.LayoutSequentialType.Attributes.ExplicitLayoutType.Attributes.AnsiClassType.Attributes.UnicodeClassType.Attributes.AutoClassアクセサーなし。 |
| FieldOffsetAttribute | フィールド オフセット。 | アクセサーなし。 |
AssemblyLoadAttribute |
CorAssemblyFlags |
アクセサーまたは列挙子はありません。 |