NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

PropertyInfo.GetAccessors (Boolean)

Returns an array of the public, and/or non-public Get and Set accessors on this property.

[Visual Basic]
Overloads MustOverride Public Function GetAccessors( _
   ByVal nonPublic As Boolean _
) As MethodInfo ()
[C#]
public abstract MethodInfo[] GetAccessors(
   bool nonPublic
);
[C++]
public: virtual MethodInfo* GetAccessors(
   bool nonPublic
) [] = 0;
[JScript]
public abstract function GetAccessors(
   nonPublic : Boolean
) : MethodInfo[];

Parameters

nonPublic
Indicates whether non-public methods should be returned in the MethodInfo array. True to include non-public methods. False to indicate only public methods.

Return Value

Value Condition
An array of MethodInfo objects representing the public or non-public accessors. Matching, public or non-public, accessors exist on this property.
An empty MethodInfo array. Matching accessors do not exist on this property.

Remarks

The array will be empty if no accessors are found.

To use the GetAccessors method, first get the class Type. From the Type, get the PropertyInfo. From the PropertyInfo, use the GetAccessors method.

Example [C#]

[C#]

//Make 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
      Type MyType = Type.GetType("Myproperty");
      PropertyInfo Mypropertyinfo = MyType.GetProperty("Caption");

      //Get the public GetAccessors Method
      MethodInfo[] Mymethodinfoarray = Mypropertyinfo.GetAccessors(true);
      Console.Write ("\nThere are "
         + Mymethodinfoarray.Count + "accessors (public)");
      
      return 0;
   }
}
Produces the following output

Reflection.PropertyInfo
There are 2 accessors (public)

See Also

PropertyInfo Class | PropertyInfo Members | System.Reflection Namespace | PropertyInfo.GetAccessors Overload List