PropertyInfo.GetGetMethod メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
このプロパティの MethodInfo アクセサーを表す get を返します。
オーバーロード
| GetGetMethod(Boolean) |
派生クラス内でオーバーライドされた場合に、このプロパティのパブリックまたは非パブリックな |
| GetGetMethod() |
このプロパティのパブリックな |
GetGetMethod(Boolean)
- ソース:
- PropertyInfo.cs
- ソース:
- PropertyInfo.cs
- ソース:
- PropertyInfo.cs
派生クラス内でオーバーライドされた場合に、このプロパティのパブリックまたは非パブリックな get アクセサーを返します。
public:
abstract System::Reflection::MethodInfo ^ GetGetMethod(bool nonPublic);
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
パブリックでない get アクセサーが返されるかどうかを示します。 パブリックでないアクセサーが返される場合は true。それ以外の場合は false。
戻り値
MethodInfo が get の場合は、このプロパティの nonPublic アクセサーを表す true オブジェクト。
null が nonPublic で false アクセサーが非パブリックの場合、または get が nonPublic でも true アクセサーが存在しない場合は、get を返します。
実装
例外
要求されたメソッドはパブリックではないメソッドのため、呼び出し元にはこのパブリックでないメソッドに反映する ReflectionPermission がありません。
例
次の例では、指定したプロパティのパブリック アクセサーまたはパブリック get 以外のアクセサーを表示します。
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 アクセサーを表す です。
メソッドを使用するには、最初に GetGetMethod クラス Typeを取得します。 から、 Typeを取得します PropertyInfo。 から、 PropertyInfoメソッドを使用します GetGetMethod 。
適用対象
GetGetMethod()
- ソース:
- PropertyInfo.cs
- ソース:
- PropertyInfo.cs
- ソース:
- PropertyInfo.cs
このプロパティのパブリックな get アクセサーを返します。
public:
System::Reflection::MethodInfo ^ GetGetMethod();
public:
virtual System::Reflection::MethodInfo ^ GetGetMethod();
public System.Reflection.MethodInfo? GetGetMethod ();
public System.Reflection.MethodInfo GetGetMethod ();
member this.GetGetMethod : unit -> System.Reflection.MethodInfo
abstract member GetGetMethod : unit -> System.Reflection.MethodInfo
override this.GetGetMethod : unit -> System.Reflection.MethodInfo
Public Function GetGetMethod () As MethodInfo
戻り値
このプロパティのパブリックな MethodInfo アクセサーを表す get オブジェクト。null アクセサーが非パブリックまたは存在しない場合は get。
実装
注釈
これは、 パラメーターが に設定された抽象 GetGetMethod メソッドの実装を nonPublic 提供する false便利なメソッドです。
メソッドを使用するには、最初に GetGetMethod クラス Typeを取得します。 から、 Typeを取得します PropertyInfo。 から、 PropertyInfoメソッドを使用します GetGetMethod 。