PropertyInfo.GetGetMethod Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Bu özellik için erişimciyi MethodInfo temsil eden bir get döndürür.
Aşırı Yüklemeler
| Name | Description |
|---|---|
| GetGetMethod(Boolean) |
Türetilmiş bir sınıfta geçersiz kılındığında, bu özellik için genel veya genel |
| GetGetMethod() |
Bu özellik için genel |
GetGetMethod(Boolean)
- Kaynak:
- PropertyInfo.cs
- Kaynak:
- PropertyInfo.cs
- Kaynak:
- PropertyInfo.cs
- Kaynak:
- PropertyInfo.cs
- Kaynak:
- PropertyInfo.cs
Türetilmiş bir sınıfta geçersiz kılındığında, bu özellik için genel veya genel get olmayan erişimciyi döndürür.
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
Parametreler
- nonPublic
- Boolean
Genel get olmayan bir erişimcinin döndürülmesi gerekip gerekmediğini gösterir.
true genel olmayan bir erişimci döndürülecekse; aksi takdirde , false.
Döndürülenler
MethodInfo iseget, bu özelliğin erişimcisini nonPublic temsil eden nesne.true Varsa nullnonPublic ve false erişimci genel değilse veya getnonPublic varsa ancak hiçbir erişimci yoksa true döndürürget.
Uygulamalar
Özel durumlar
İstenen yöntem genel değil ve çağıranın bu genel olmayan yöntemi yansıtması gerekmez ReflectionPermission .
Örnekler
Aşağıdaki örnek, belirtilen özellik için genel veya genel get olmayan erişimciyi görüntüler.
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
Açıklamalar
Bu özellik get erişimcisini temsil eden özelliktir MethodInfo .
yöntemini kullanmak GetGetMethod için önce sınıfını Typealın. ' Typeden öğesini alın PropertyInfo. içinden PropertyInfoyöntemini kullanın GetGetMethod .
Şunlara uygulanır
GetGetMethod()
- Kaynak:
- PropertyInfo.cs
- Kaynak:
- PropertyInfo.cs
- Kaynak:
- PropertyInfo.cs
- Kaynak:
- PropertyInfo.cs
- Kaynak:
- PropertyInfo.cs
Bu özellik için genel get erişimciyi döndürür.
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
Döndürülenler
MethodInfo Bu özellik için genel get erişimciyi temsil eden veya nullget erişimci genel olmayan veya mevcut değilse bir nesne.
Uygulamalar
Açıklamalar
Bu, parametresi olarak ayarlanmış soyut GetGetMethod yöntem için bir uygulama sağlayan bir kolaylık yöntemidir nonPublicfalse.
yöntemini kullanmak GetGetMethod için önce sınıfını Typealın. ' Typeden öğesini alın PropertyInfo. içinden PropertyInfoyöntemini kullanın GetGetMethod .