DynamicMethod.ReturnTypeCustomAttributes 속성

정의

동적 메서드에 대한 반환 형식의 사용자 지정 특성을 가져옵니다.

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

동적 메서드에 대한 반환 형식의 사용자 지정 특성을 나타내는 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 사용자 지정 특성의 배열은 항상 비어 있습니다.

적용 대상

추가 정보