PropertyInfo.GetSetMethod 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 set döndürür.
Aşırı Yüklemeler
| Name | Description |
|---|---|
| GetSetMethod(Boolean) |
Türetilmiş bir sınıfta geçersiz kılındığında, bu özelliğin erişimcisini |
| GetSetMethod() |
Bu özellik için genel |
GetSetMethod(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 özelliğin erişimcisini set döndürür.
public:
abstract System::Reflection::MethodInfo ^ GetSetMethod(bool nonPublic);
public abstract System.Reflection.MethodInfo? GetSetMethod(bool nonPublic);
public abstract System.Reflection.MethodInfo GetSetMethod(bool nonPublic);
abstract member GetSetMethod : bool -> System.Reflection.MethodInfo
Public MustOverride Function GetSetMethod (nonPublic As Boolean) As MethodInfo
Parametreler
- nonPublic
- Boolean
Erişimcinin genel kullanıma açık değilse 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
Bu özelliğin Set yöntemi veya nullaşağıdaki tabloda gösterildiği gibi.
| Değer | Koşul |
|---|---|
Set Bu özelliğin yöntemi.
| Erişimci set genel, OR nonPublic ise true ve set erişimci genel değil.
|
null |
nonPublic şeklindedir true, ancak özellik salt okunur, OR nonPublic ise false ve set erişimci genel değil VEYA erişimci yok set .
|
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 özelliğin set erişimcisini 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.Text.StringBuilder");
PropertyInfo Mypropertyinfob = MyTypeb.GetProperty("Length");
// Get and display the GetSetMethod method for each property.
MethodInfo Mygetmethodinfoa = Mypropertyinfoa.GetSetMethod();
Console.Write ("\nSetAccessor for " + Mypropertyinfoa.Name
+ " returns a " + Mygetmethodinfoa.ReturnType);
MethodInfo Mygetmethodinfob = Mypropertyinfob.GetSetMethod();
Console.Write ("\nSetAccessor for " + Mypropertyinfob.Name
+ " returns a " + Mygetmethodinfob.ReturnType);
// Display the GetSetMethod without using the MethodInfo.
Console.Write ("\n\n" + MyTypea.FullName + "."
+ Mypropertyinfoa.Name + " GetSetMethod - "
+ Mypropertyinfoa.GetSetMethod());
Console.Write ("\n" + MyTypeb.FullName + "."
+ Mypropertyinfob.Name + " GetSetMethod - "
+ Mypropertyinfob.GetSetMethod());
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.Text.StringBuilder")
Dim Mypropertyinfob As PropertyInfo = MyTypeb.GetProperty("Length")
' Get and display the GetSetMethod method for each property.
Dim Mygetmethodinfoa As MethodInfo = Mypropertyinfoa.GetSetMethod()
Console.WriteLine("SetAccessor for " & Mypropertyinfoa.Name & _
" returns a " & Mygetmethodinfoa.ReturnType.ToString())
Dim Mygetmethodinfob As MethodInfo = Mypropertyinfob.GetSetMethod()
Console.WriteLine("SetAccessor for " & Mypropertyinfob.Name & _
" returns a " & Mygetmethodinfob.ReturnType.ToString())
' Display the GetSetMethod without using the MethodInfo.
Console.WriteLine(MyTypea.FullName & "." & Mypropertyinfoa.Name & _
" GetSetMethod - " & Mypropertyinfoa.GetSetMethod().ToString())
Console.WriteLine(MyTypeb.FullName & "." & Mypropertyinfob.Name & _
" GetSetMethod - " & Mypropertyinfob.GetSetMethod().ToString())
Return 0
End Function
End Class
Açıklamalar
yöntemini kullanmak GetSetMethod için önce sınıfını Typealın. ' Typeden öğesini alın PropertyInfo. içinden PropertyInfoyöntemini kullanın GetSetMethod .
Şunlara uygulanır
GetSetMethod()
- Kaynak:
- PropertyInfo.cs
- Kaynak:
- PropertyInfo.cs
- Kaynak:
- PropertyInfo.cs
- Kaynak:
- PropertyInfo.cs
- Kaynak:
- PropertyInfo.cs
Bu özellik için genel set erişimciyi döndürür.
public:
System::Reflection::MethodInfo ^ GetSetMethod();
public:
virtual System::Reflection::MethodInfo ^ GetSetMethod();
public System.Reflection.MethodInfo? GetSetMethod();
public System.Reflection.MethodInfo GetSetMethod();
member this.GetSetMethod : unit -> System.Reflection.MethodInfo
abstract member GetSetMethod : unit -> System.Reflection.MethodInfo
override this.GetSetMethod : unit -> System.Reflection.MethodInfo
Public Function GetSetMethod () As MethodInfo
Döndürülenler
Erişimci MethodInfo genelse Set veya set erişimci genel değilse, bu özelliğin yöntemini temsil eden nullset nesne.
Uygulamalar
Açıklamalar
Bu, parametresi olarak ayarlanmış soyut GetSetMethod yöntem için bir uygulama sağlayan bir kolaylık yöntemidir nonPublicfalse.
yöntemini kullanmak GetSetMethod için önce sınıfını Typealın. ' Typeden öğesini alın PropertyInfo. içinden PropertyInfoyöntemini kullanın GetSetMethod .