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

検索する属性の種類。

戻り値

Attribute

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

例外

element または attributeTypenull です。

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

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

注釈

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

適用対象

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

検索する属性の種類。

戻り値

Attribute

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

例外

element または attributeTypenull です。

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

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

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

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

注釈

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

適用対象

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

検索する属性の種類。

戻り値

Attribute

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

例外

element または attributeTypenull です。

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

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

注釈

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

適用対象

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

検索する属性の種類。

戻り値

Attribute

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

例外

element または attributeTypenull です。

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

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

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

注釈

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

適用対象

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

element の先祖を調べる場合は true。それ以外の場合は false

戻り値

Attribute

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

例外

element または attributeTypenull です。

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

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

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

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

注釈

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

適用対象

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

element の先祖を調べる場合は true。それ以外の場合は false

戻り値

Attribute

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

例外

element または attributeTypenull です。

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

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

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

注釈

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

適用対象

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;
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

element の先祖を調べる場合は true。それ以外の場合は false

戻り値

T

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

例外

elementnullです。

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

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

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

注釈

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

適用対象

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;
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

element の先祖を調べる場合は true。それ以外の場合は false

戻り値

T

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

例外

elementnullです。

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

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

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

注釈

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

適用対象

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;
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がコンストラクター、メソッド、プロパティ、イベント、型、またはフィールドではありません。

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

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

注釈

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

適用対象

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;
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です。

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

注釈

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

適用対象

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;
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がコンストラクター、メソッド、プロパティ、イベント、型、またはフィールドではありません。

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

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

注釈

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

適用対象

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;
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です。

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

注釈

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

適用対象