DynamicMethod.ReturnTypeCustomAttributes プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DynamicMethod.ReturnTypeCustomAttributes プロパティの意味・解説 

DynamicMethod.ReturnTypeCustomAttributes プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

動的メソッド戻り値の型のカスタム属性取得します

名前空間: System.Reflection.Emit
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Overrides ReadOnly
 Property ReturnTypeCustomAttributes As ICustomAttributeProvider
Dim instance As DynamicMethod
Dim value As ICustomAttributeProvider

value = instance.ReturnTypeCustomAttributes
public override ICustomAttributeProvider ReturnTypeCustomAttributes
 { get; }
public:
virtual property ICustomAttributeProvider^ ReturnTypeCustomAttributes {
    ICustomAttributeProvider^ get () override;
}
/** @property */
public ICustomAttributeProvider get_ReturnTypeCustomAttributes
 ()
public override function get
 ReturnTypeCustomAttributes () : ICustomAttributeProvider

プロパティ
動的メソッド戻り値の型のカスタム属性を表す ICustomAttributeProvider。

解説解説

カスタム属性は、動的メソッド戻り値の型ではサポートされていないため、GetCustomAttributes メソッドによって返されるカスタム属性配列は常に空です。

使用例使用例

動的メソッド戻り値の型のカスタム属性表示する方法次のコード例示します。このコード例は、DynamicMethod クラストピック取り上げているコード例一部分です。

' ReturnTypeCustomAttributes returns an ICustomeAttributeProvider
' that can be used to enumerate the custom attributes of the
' return value. At present, there is no way to set such custom
' attributes, so the list is empty.
If hello.ReturnType Is GetType(System.Void)
 Then
    Console.WriteLine("The method has no return type.")
Else
    Dim caProvider As ICustomAttributeProvider
 = _
        hello.ReturnTypeCustomAttributes
    Dim returnAttributes() As Object
 = _
        caProvider.GetCustomAttributes(True)
    If returnAttributes.Length = 0 Then
        Console.WriteLine(vbCrLf _
            & "The return type has no custom attributes.")
    Else
        Console.WriteLine(vbCrLf _
            & "The return type has the following custom attributes:")
        For Each attr As
 Object In returnAttributes
            Console.WriteLine(vbTab & attr.ToString())
        Next attr
    End If
End If
// ReturnTypeCustomAttributes returns an ICustomeAttributeProvider
// that can be used to enumerate the custom attributes of the
// return value. At present, there is no way to set such custom
// attributes, so the list is empty.
if (hello.ReturnType == typeof(void))
{
    Console.WriteLine("The method has no return type.");
}
else
{
    ICustomAttributeProvider caProvider = hello.ReturnTypeCustomAttributes;
    object[] returnAttributes = caProvider.GetCustomAttributes(true);
    if (returnAttributes.Length==0)
    {
        Console.WriteLine("\r\nThe return type has no custom
 attributes.");
    }
    else
    {
        Console.WriteLine("\r\nThe return type has the following
 custom attributes:");
        foreach( object attr in returnAttributes
 )
        {
            Console.WriteLine("\t{0}", attr.ToString());
        }
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DynamicMethod クラス
DynamicMethod メンバ
System.Reflection.Emit 名前空間
DynamicMethod.ReturnType プロパティ



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

DynamicMethod.ReturnTypeCustomAttributes プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DynamicMethod.ReturnTypeCustomAttributes プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS