DynamicMethod.ReturnTypeCustomAttributes プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
動的メソッドの戻り値の型のカスタム属性を取得します。
public:
virtual property System::Reflection::ICustomAttributeProvider ^ ReturnTypeCustomAttributes { System::Reflection::ICustomAttributeProvider ^ get(); };
public override System.Reflection.ICustomAttributeProvider ReturnTypeCustomAttributes { get; }
member this.ReturnTypeCustomAttributes : System.Reflection.ICustomAttributeProvider
Public Overrides ReadOnly Property ReturnTypeCustomAttributes As ICustomAttributeProvider
プロパティ値
動的メソッドの戻り値の型のカスタム属性を表す ICustomAttributeProvider。
例
次のコード例は、動的メソッドの戻り値の型のカスタム属性を表示する方法を示しています。 このコード例は、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 == Void::typeid)
{
Console::WriteLine("The method has no return type.");
}
else
{
ICustomAttributeProvider^ caProvider = hello->ReturnTypeCustomAttributes;
array<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:");
for each (Object^ attr in returnAttributes)
{
Console::WriteLine("\t{0}", attr->ToString());
}
}
}
// 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());
}
}
}
' 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
注釈
カスタム属性は動的メソッドの戻り値の型ではサポートされていないため、メソッドによって GetCustomAttributes 返されるカスタム属性の配列は常に空です。
適用対象
こちらもご覧ください
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET