PropertyInfo.GetGetMethod PropertyInfo.GetGetMethod PropertyInfo.GetGetMethod PropertyInfo.GetGetMethod Method

定義

このプロパティの MethodInfo アクセサーを表す get を返します。Returns a MethodInfo representing the get accessor for this property.

オーバーロード

GetGetMethod() GetGetMethod() GetGetMethod() GetGetMethod()

このプロパティのパブリックな get アクセサーを返します。Returns the public get accessor for this property.

GetGetMethod(Boolean) GetGetMethod(Boolean) GetGetMethod(Boolean) GetGetMethod(Boolean)

派生クラス内でオーバーライドされた場合に、このプロパティのパブリックまたは非パブリックな get アクセサーを返します。When overridden in a derived class, returns the public or non-public get accessor for this property.

GetGetMethod() GetGetMethod() GetGetMethod() GetGetMethod()

このプロパティのパブリックな get アクセサーを返します。Returns the public get accessor for this property.

public:
 virtual System::Reflection::MethodInfo ^ GetGetMethod();
public System.Reflection.MethodInfo GetGetMethod ();
abstract member GetGetMethod : unit -> System.Reflection.MethodInfo
override this.GetGetMethod : unit -> System.Reflection.MethodInfo
Public Function GetGetMethod () As MethodInfo

戻り値

このプロパティのパブリックな MethodInfo アクセサーを表す get オブジェクト。null アクセサーが非パブリックまたは存在しない場合は getA MethodInfo object representing the public get accessor for this property, or null if the get accessor is non-public or does not exist.

実装

注釈

これは、 GetGetMethod nonPublicパラメーターをにfalse設定して抽象メソッドの実装を提供する便利なメソッドです。This is a convenience method that provides an implementation for the abstract GetGetMethod method with the nonPublic parameter set to false.

GetGetMethodメソッドを使用するには、まずクラスTypeを取得します。To use the GetGetMethod method, first get the class Type. から、 PropertyInfoを取得します。 TypeFrom the Type, get the PropertyInfo. から、 GetGetMethodメソッドを使用します。 PropertyInfoFrom the PropertyInfo, use the GetGetMethod method.

セキュリティ

ReflectionPermission
などの機構をInvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[])使用して遅延バインディングが呼び出された場合。when invoked late-bound through mechanisms such as InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[]). MemberAccess (関連する列挙体)Associated enumeration: MemberAccess.

GetGetMethod(Boolean) GetGetMethod(Boolean) GetGetMethod(Boolean) GetGetMethod(Boolean)

派生クラス内でオーバーライドされた場合に、このプロパティのパブリックまたは非パブリックな get アクセサーを返します。When overridden in a derived class, returns the public or non-public get accessor for this property.

public:
 abstract System::Reflection::MethodInfo ^ GetGetMethod(bool nonPublic);
public abstract System.Reflection.MethodInfo GetGetMethod (bool nonPublic);
abstract member GetGetMethod : bool -> System.Reflection.MethodInfo
Public MustOverride Function GetGetMethod (nonPublic As Boolean) As MethodInfo

パラメーター

nonPublic
Boolean Boolean Boolean Boolean

パブリックでない get アクセサーが返されるかどうかを示します。Indicates whether a non-public get accessor should be returned. パブリックでないアクセサーが返される場合は true。それ以外の場合は falsetrue if a non-public accessor is to be returned; otherwise, false.

戻り値

MethodInfoget の場合は、このプロパティの nonPublic アクセサーを表す true オブジェクト。A MethodInfo object representing the get accessor for this property, if nonPublic is true. nullnonPublicfalse アクセサーが非パブリックの場合、または getnonPublic でも true アクセサーが存在しない場合は、get を返します。Returns null if nonPublic is false and the get accessor is non-public, or if nonPublic is true but no get accessors exist.

実装

例外

要求されたメソッドはパブリックではないメソッドのため、呼び出し元にはこのパブリックでないメソッドに反映する ReflectionPermission がありません。The requested method is non-public and the caller does not have ReflectionPermission to reflect on this non-public method.

次の例では、指定されたgetプロパティのパブリックまたは非パブリックなアクセサーを表示します。The following example displays the public or non-public get accessor for the specified property.

using namespace System;
using namespace System::Reflection;

// Define a property.
public ref class Myproperty
{
private:
   String^ caption;

public:
   Myproperty()
      : caption( "A Default caption" )
   {}


   property String^ Caption 
   {
      String^ get()
      {
         return caption;
      }

      void set( String^ value )
      {
         if ( caption != value )
         {
            caption = value;
         }
      }

   }

};

int main()
{
   Console::WriteLine( "\nReflection.PropertyInfo" );
   
   // Get the type and PropertyInfo for two separate properties.
   Type^ MyTypea = Type::GetType( "Myproperty" );
   PropertyInfo^ Mypropertyinfoa = MyTypea->GetProperty( "Caption" );
   Type^ MyTypeb = Type::GetType( "System.Reflection.MethodInfo" );
   PropertyInfo^ Mypropertyinfob = MyTypeb->GetProperty( "MemberType" );
   
   // Get and display the GetGetMethod method for each property.
   MethodInfo^ Mygetmethodinfoa = Mypropertyinfoa->GetGetMethod();
   Console::Write( "\nGetAccessor for {0} returns a {1}", Mypropertyinfoa->Name, Mygetmethodinfoa->ReturnType );
   MethodInfo^ Mygetmethodinfob = Mypropertyinfob->GetGetMethod();
   Console::Write( "\nGetAccessor for {0} returns a {1}", Mypropertyinfob->Name, Mygetmethodinfob->ReturnType );
   
   // Display the GetGetMethod without using the MethodInfo.
   Console::Write( "\n{0}.{1} GetGetMethod - {2}", MyTypea->FullName, Mypropertyinfoa->Name, Mypropertyinfoa->GetGetMethod() );
   Console::Write( "\n{0}.{1} GetGetMethod - {2}", MyTypeb->FullName, Mypropertyinfob->Name, Mypropertyinfob->GetGetMethod() );
   return 0;
}

using System;
using System.Reflection;
 
// Define a property.
public class Myproperty   
{
    private string caption = "A Default caption";
    public string Caption
    {
        get{return caption;}
        set {if(caption!=value) {caption = value;}
        }
    }
}
 
class Mypropertyinfo
{
    public static int Main()
    {
        Console.WriteLine ("\nReflection.PropertyInfo");
 
        // Get the type and PropertyInfo for two separate properties.
        Type MyTypea = Type.GetType("Myproperty");
        PropertyInfo Mypropertyinfoa = MyTypea.GetProperty("Caption");
        Type MyTypeb = Type.GetType("System.Reflection.MethodInfo");
        PropertyInfo Mypropertyinfob = MyTypeb.GetProperty("MemberType");
 
        // Get and display the GetGetMethod method for each property.
        MethodInfo Mygetmethodinfoa = Mypropertyinfoa.GetGetMethod();
        Console.Write ("\nGetAccessor for " + Mypropertyinfoa.Name
            + " returns a " + Mygetmethodinfoa.ReturnType);
        MethodInfo Mygetmethodinfob = Mypropertyinfob.GetGetMethod();
        Console.Write ("\nGetAccessor for " + Mypropertyinfob.Name
            + " returns a " + Mygetmethodinfob.ReturnType);
 
        // Display the GetGetMethod without using the MethodInfo.
        Console.Write ("\n" + MyTypea.FullName + "." + Mypropertyinfoa.Name
            + " GetGetMethod - " + Mypropertyinfoa.GetGetMethod());
        Console.Write ("\n" + MyTypeb.FullName + "." + Mypropertyinfob.Name
            + " GetGetMethod - " + Mypropertyinfob.GetGetMethod());
        return 0;
    }
}
Imports System.Reflection

' Define a property.
Public Class Myproperty
    Private myCaption As String = "A Default caption"

    Public Property Caption() As String
        Get
            Return myCaption
        End Get
        Set(ByVal Value As String)
            If myCaption <> value Then
                myCaption = value
            End If
        End Set
    End Property
End Class

Class Mypropertyinfo

    Public Shared Function Main() As Integer
        Console.WriteLine(ControlChars.CrLf & "Reflection.PropertyInfo")

        ' Get the type and PropertyInfo for two separate properties.
        Dim MyTypea As Type = Type.GetType("Myproperty")
        Dim Mypropertyinfoa As PropertyInfo = MyTypea.GetProperty("Caption")
        Dim MyTypeb As Type = Type.GetType("System.Reflection.MethodInfo")
        Dim Mypropertyinfob As PropertyInfo = MyTypeb.GetProperty("MemberType")

        ' Get and display the GetGetMethod Method for each property.
        Dim Mygetmethodinfoa As MethodInfo = Mypropertyinfoa.GetGetMethod()
        Console.WriteLine("GetAccessor for " & _
           Mypropertyinfoa.Name & " returns a " & _
           Mygetmethodinfoa.ReturnType.ToString())
        Dim Mygetmethodinfob As MethodInfo = Mypropertyinfob.GetGetMethod()
        Console.WriteLine("GetAccessor for " & _
           Mypropertyinfob.Name & " returns a " & _
           Mygetmethodinfob.ReturnType.ToString())

        ' Display the GetGetMethod without using the MethodInfo.
        Console.WriteLine(MyTypea.FullName & "." & _
           Mypropertyinfoa.Name & " GetGetMethod - " & _
           Mypropertyinfoa.GetGetMethod().ToString())
        Console.WriteLine(MyTypeb.FullName & "." & _
           Mypropertyinfob.Name & " GetGetMethod - " & _
           Mypropertyinfob.GetGetMethod().ToString())
        Return 0
    End Function
End Class

注釈

このプロパティは、 MethodInfo get アクセサーを表すです。This property is the MethodInfo representing the get accessor.

GetGetMethodメソッドを使用するには、まずクラスTypeを取得します。To use the GetGetMethod method, first get the class Type. から、 PropertyInfoを取得します。 TypeFrom the Type, get the PropertyInfo. から、 GetGetMethodメソッドを使用します。 PropertyInfoFrom the PropertyInfo, use the GetGetMethod method.

セキュリティ

ReflectionPermission
などの機構をInvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[])使用して遅延バインディングが呼び出された場合。when invoked late-bound through mechanisms such as InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[]). MemberAccess (関連する列挙体)Associated enumeration: MemberAccess.

適用対象