CustomAttributeExtensions.GetCustomAttribute メソッド

定義

指定した要素に適用されるカスタム属性を取得します。

オーバーロード

名前 説明
GetCustomAttribute(Assembly, Type)

指定したアセンブリに適用される、指定した型のカスタム属性を取得します。

GetCustomAttribute(MemberInfo, Type)

指定したメンバーに適用される、指定した型のカスタム属性を取得します。

GetCustomAttribute(Module, Type)

指定したモジュールに適用される、指定した型のカスタム属性を取得します。

GetCustomAttribute(ParameterInfo, Type)

指定したパラメーターに適用される、指定した型のカスタム属性を取得します。

GetCustomAttribute(MemberInfo, Type, Boolean)

指定したメンバーに適用される、指定した型のカスタム属性を取得し、必要に応じてそのメンバーの先祖を検査します。

GetCustomAttribute(ParameterInfo, Type, Boolean)

指定したパラメーターに適用される、指定した型のカスタム属性を取得し、必要に応じてそのパラメーターの先祖を検査します。

GetCustomAttribute<T>(ParameterInfo, Boolean)

指定したパラメーターに適用される、指定した型のカスタム属性を取得し、必要に応じてそのパラメーターの先祖を検査します。

GetCustomAttribute<T>(MemberInfo, Boolean)

指定したメンバーに適用される、指定した型のカスタム属性を取得し、必要に応じてそのメンバーの先祖を検査します。

GetCustomAttribute<T>(ParameterInfo)

指定したパラメーターに適用される、指定した型のカスタム属性を取得します。

GetCustomAttribute<T>(Module)

指定したモジュールに適用される、指定した型のカスタム属性を取得します。

GetCustomAttribute<T>(MemberInfo)

指定したメンバーに適用される、指定した型のカスタム属性を取得します。

GetCustomAttribute<T>(Assembly)

指定したアセンブリに適用される、指定した型のカスタム属性を取得します。

GetCustomAttribute(Assembly, Type)

指定したアセンブリに適用される、指定した型のカスタム属性を取得します。

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::Assembly ^ element, Type ^ attributeType);
public static Attribute GetCustomAttribute(this System.Reflection.Assembly element, Type attributeType);
static member GetCustomAttribute : System.Reflection.Assembly * Type -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As Assembly, attributeType As Type) As Attribute

パラメーター

element
Assembly

検査するアセンブリ。

attributeType
Type

検索する属性の種類。

返品

attributeTypeに一致するカスタム属性。そのような属性が見つからない場合はnull

例外

element または attributeTypenull

attributeTypeAttributeから派生していません。

要求された属性が複数見つかりました。

注釈

複数の値が返されると予想される場合、またはAmbiguousMatchExceptionがスローされる場合は、GetCustomAttributes拡張メソッドを使用します。

適用対象

GetCustomAttribute(MemberInfo, Type)

指定したメンバーに適用される、指定した型のカスタム属性を取得します。

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::MemberInfo ^ element, Type ^ attributeType);
public static Attribute GetCustomAttribute(this System.Reflection.MemberInfo element, Type attributeType);
static member GetCustomAttribute : System.Reflection.MemberInfo * Type -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As MemberInfo, attributeType As Type) As Attribute

パラメーター

element
MemberInfo

検査するメンバー。

attributeType
Type

検索する属性の種類。

返品

attributeTypeに一致するカスタム属性。そのような属性が見つからない場合はnull

例外

element または attributeTypenull

attributeTypeAttributeから派生していません。

element は、コンストラクター、メソッド、プロパティ、イベント、型、またはフィールドではありません。

要求された属性が複数見つかりました。

カスタム属性の型を読み込むことができません。

注釈

複数の値が返されると予想される場合、またはAmbiguousMatchExceptionがスローされる場合は、GetCustomAttributes拡張メソッドを使用します。

適用対象

GetCustomAttribute(Module, Type)

指定したモジュールに適用される、指定した型のカスタム属性を取得します。

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::Module ^ element, Type ^ attributeType);
public static Attribute GetCustomAttribute(this System.Reflection.Module element, Type attributeType);
static member GetCustomAttribute : System.Reflection.Module * Type -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As Module, attributeType As Type) As Attribute

パラメーター

element
Module

検査するモジュール。

attributeType
Type

検索する属性の種類。

返品

attributeTypeに一致するカスタム属性。そのような属性が見つからない場合はnull

例外

element または attributeTypenull

attributeTypeAttributeから派生していません。

要求された属性が複数見つかりました。

注釈

複数の値が返されると予想される場合、またはAmbiguousMatchExceptionがスローされる場合は、GetCustomAttributes拡張メソッドを使用します。

適用対象

GetCustomAttribute(ParameterInfo, Type)

指定したパラメーターに適用される、指定した型のカスタム属性を取得します。

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::ParameterInfo ^ element, Type ^ attributeType);
public static Attribute GetCustomAttribute(this System.Reflection.ParameterInfo element, Type attributeType);
static member GetCustomAttribute : System.Reflection.ParameterInfo * Type -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As ParameterInfo, attributeType As Type) As Attribute

パラメーター

element
ParameterInfo

検査するパラメーター。

attributeType
Type

検索する属性の種類。

返品

attributeTypeに一致するカスタム属性。そのような属性が見つからない場合はnull

例外

element または attributeTypenull

attributeTypeAttributeから派生していません。

要求された属性が複数見つかりました。

カスタム属性の型を読み込むことができません。

注釈

複数の値が返されると予想される場合、またはAmbiguousMatchExceptionがスローされる場合は、GetCustomAttributes拡張メソッドを使用します。

適用対象

GetCustomAttribute(MemberInfo, Type, Boolean)

指定したメンバーに適用される、指定した型のカスタム属性を取得し、必要に応じてそのメンバーの先祖を検査します。

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::MemberInfo ^ element, Type ^ attributeType, bool inherit);
public static Attribute GetCustomAttribute(this System.Reflection.MemberInfo element, Type attributeType, bool inherit);
static member GetCustomAttribute : System.Reflection.MemberInfo * Type * bool -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As MemberInfo, attributeType As Type, inherit As Boolean) As Attribute

パラメーター

element
MemberInfo

検査するメンバー。

attributeType
Type

検索する属性の種類。

inherit
Boolean

true elementの先祖を検査する場合は。それ以外の場合はfalse

返品

attributeTypeに一致するカスタム属性。そのような属性が見つからない場合はnull

例外

element または attributeTypenull

attributeTypeAttributeから派生していません。

element は、コンストラクター、メソッド、プロパティ、イベント、型、またはフィールドではありません。

要求された属性が複数見つかりました。

カスタム属性の型を読み込むことができません。

注釈

複数の値が返されると予想される場合、またはAmbiguousMatchExceptionがスローされる場合は、GetCustomAttributes拡張メソッドを使用します。

適用対象

GetCustomAttribute(ParameterInfo, Type, Boolean)

指定したパラメーターに適用される、指定した型のカスタム属性を取得し、必要に応じてそのパラメーターの先祖を検査します。

public:
[System::Runtime::CompilerServices::Extension]
 static Attribute ^ GetCustomAttribute(System::Reflection::ParameterInfo ^ element, Type ^ attributeType, bool inherit);
public static Attribute GetCustomAttribute(this System.Reflection.ParameterInfo element, Type attributeType, bool inherit);
static member GetCustomAttribute : System.Reflection.ParameterInfo * Type * bool -> Attribute
<Extension()>
Public Function GetCustomAttribute (element As ParameterInfo, attributeType As Type, inherit As Boolean) As Attribute

パラメーター

element
ParameterInfo

検査するパラメーター。

attributeType
Type

検索する属性の種類。

inherit
Boolean

true elementの先祖を検査する場合は。それ以外の場合はfalse

返品

attributeTypeに一致するカスタム属性。そのような属性が見つからない場合はnull

例外

element または attributeTypenull

attributeTypeAttributeから派生していません。

要求された属性が複数見つかりました。

カスタム属性の型を読み込むことができません。

注釈

複数の値が返されると予想される場合、またはAmbiguousMatchExceptionがスローされる場合は、GetCustomAttributes拡張メソッドを使用します。

適用対象

GetCustomAttribute<T>(ParameterInfo, Boolean)

指定したパラメーターに適用される、指定した型のカスタム属性を取得し、必要に応じてそのパラメーターの先祖を検査します。

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::ParameterInfo ^ element, bool inherit);
public static T GetCustomAttribute<T>(this System.Reflection.ParameterInfo element, bool inherit) where T : Attribute;
static member GetCustomAttribute : System.Reflection.ParameterInfo * bool -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As ParameterInfo, inherit As Boolean) As T

型パラメーター

T

検索する属性の種類。

パラメーター

element
ParameterInfo

検査するパラメーター。

inherit
Boolean

true elementの先祖を検査する場合は。それ以外の場合はfalse

返品

T

Tに一致するカスタム属性。そのような属性が見つからない場合はnull

例外

elementnullです。

element は、コンストラクター、メソッド、プロパティ、イベント、型、またはフィールドではありません。

要求された属性が複数見つかりました。

カスタム属性の型を読み込むことができません。

注釈

複数の値が返されると予想される場合、またはAmbiguousMatchExceptionがスローされる場合は、GetCustomAttributes拡張メソッドを使用します。

適用対象

GetCustomAttribute<T>(MemberInfo, Boolean)

指定したメンバーに適用される、指定した型のカスタム属性を取得し、必要に応じてそのメンバーの先祖を検査します。

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::MemberInfo ^ element, bool inherit);
public static T GetCustomAttribute<T>(this System.Reflection.MemberInfo element, bool inherit) where T : Attribute;
static member GetCustomAttribute : System.Reflection.MemberInfo * bool -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As MemberInfo, inherit As Boolean) As T

型パラメーター

T

検索する属性の種類。

パラメーター

element
MemberInfo

検査するメンバー。

inherit
Boolean

true elementの先祖を検査する場合は。それ以外の場合はfalse

返品

T

Tに一致するカスタム属性。そのような属性が見つからない場合はnull

例外

elementnullです。

element は、コンストラクター、メソッド、プロパティ、イベント、型、またはフィールドではありません。

要求された属性が複数見つかりました。

カスタム属性の型を読み込むことができません。

注釈

複数の値が返されると予想される場合、またはAmbiguousMatchExceptionがスローされる場合は、GetCustomAttributes拡張メソッドを使用します。

適用対象

GetCustomAttribute<T>(ParameterInfo)

指定したパラメーターに適用される、指定した型のカスタム属性を取得します。

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::ParameterInfo ^ element);
public static T GetCustomAttribute<T>(this System.Reflection.ParameterInfo element) where T : Attribute;
static member GetCustomAttribute : System.Reflection.ParameterInfo -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As ParameterInfo) As T

型パラメーター

T

検索する属性の種類。

パラメーター

element
ParameterInfo

検査するパラメーター。

返品

T

Tに一致するカスタム属性。そのような属性が見つからない場合はnull

例外

elementnullです。

element は、コンストラクター、メソッド、プロパティ、イベント、型、またはフィールドではありません。

要求された属性が複数見つかりました。

カスタム属性の型を読み込むことができません。

注釈

複数の値が返されると予想される場合、またはAmbiguousMatchExceptionがスローされる場合は、GetCustomAttributes拡張メソッドを使用します。

適用対象

GetCustomAttribute<T>(Module)

指定したモジュールに適用される、指定した型のカスタム属性を取得します。

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::Module ^ element);
public static T GetCustomAttribute<T>(this System.Reflection.Module element) where T : Attribute;
static member GetCustomAttribute : System.Reflection.Module -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As Module) As T

型パラメーター

T

検索する属性の種類。

パラメーター

element
Module

検査するモジュール。

返品

T

Tに一致するカスタム属性。そのような属性が見つからない場合はnull

例外

elementnullです。

要求された属性が複数見つかりました。

注釈

複数の値が返されると予想される場合、またはAmbiguousMatchExceptionがスローされる場合は、GetCustomAttributes拡張メソッドを使用します。

適用対象

GetCustomAttribute<T>(MemberInfo)

指定したメンバーに適用される、指定した型のカスタム属性を取得します。

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::MemberInfo ^ element);
public static T GetCustomAttribute<T>(this System.Reflection.MemberInfo element) where T : Attribute;
static member GetCustomAttribute : System.Reflection.MemberInfo -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As MemberInfo) As T

型パラメーター

T

検索する属性の種類。

パラメーター

element
MemberInfo

検査するメンバー。

返品

T

Tに一致するカスタム属性。そのような属性が見つからない場合はnull

例外

elementnullです。

element は、コンストラクター、メソッド、プロパティ、イベント、型、またはフィールドではありません。

要求された属性が複数見つかりました。

カスタム属性の型を読み込むことができません。

注釈

複数の値が返されると予想される場合、またはAmbiguousMatchExceptionがスローされる場合は、GetCustomAttributes拡張メソッドを使用します。

適用対象

GetCustomAttribute<T>(Assembly)

指定したアセンブリに適用される、指定した型のカスタム属性を取得します。

public:
generic <typename T>
 where T : Attribute[System::Runtime::CompilerServices::Extension]
 static T GetCustomAttribute(System::Reflection::Assembly ^ element);
public static T GetCustomAttribute<T>(this System.Reflection.Assembly element) where T : Attribute;
static member GetCustomAttribute : System.Reflection.Assembly -> 'T (requires 'T :> Attribute)
<Extension()>
Public Function GetCustomAttribute(Of T As Attribute) (element As Assembly) As T

型パラメーター

T

検索する属性の種類。

パラメーター

element
Assembly

検査するアセンブリ。

返品

T

Tに一致するカスタム属性。そのような属性が見つからない場合はnull

例外

elementnullです。

要求された属性が複数見つかりました。

注釈

複数の値が返されると予想される場合、またはAmbiguousMatchExceptionがスローされる場合は、GetCustomAttributes拡張メソッドを使用します。

適用対象