次の方法で共有


AttributeTable.GetCustomAttributes メソッド (Type, String)

指定した型とメンバー名に対して提供されるすべての属性の列挙体を返します。

名前空間:  Microsoft.Windows.Design.Metadata
アセンブリ:  Microsoft.Windows.Design.Extensibility (Microsoft.Windows.Design.Extensibility.dll 内)

構文

'宣言
Public Function GetCustomAttributes ( _
    ownerType As Type, _
    memberName As String _
) As IEnumerable
public IEnumerable GetCustomAttributes(
    Type ownerType,
    string memberName
)
public:
IEnumerable^ GetCustomAttributes(
    Type^ ownerType, 
    String^ memberName
)
member GetCustomAttributes : 
        ownerType:Type * 
        memberName:string -> IEnumerable 
public function GetCustomAttributes(
    ownerType : Type, 
    memberName : String
) : IEnumerable

パラメーター

  • ownerType
    型: System.Type
    依存関係プロパティを所有する型。
  • memberName
    型: System.String
    属性が提供されるメンバーの名前。

戻り値

型: System.Collections.IEnumerable
属性の列挙体。

例外

例外 条件
ArgumentNullException

ownerType または memberName が nullnull 参照 (Visual Basic では Nothing) です。

解説

このメソッドでは、nullnull 参照 (Visual Basic では Nothing) 列挙体が返されることはありません。

GetCustomAttributes メソッドを使用して、メンバーのカスタム属性を取得する方法を次のコード例に示します。 次のコード例は、AttributeTable クラス用のより大きなコード例の一部です。

Dim attrs1 As IEnumerable = attributes.GetCustomAttributes(GetType(Button), "Background")
IEnumerable attrs1 = attributes.GetCustomAttributes(
    typeof(Button),
    "Background");

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

AttributeTable クラス

GetCustomAttributes オーバーロード

Microsoft.Windows.Design.Metadata 名前空間

AttributeTableBuilder