Identify classes in the Progress.Reflect package
- Last Updated: October 8, 2020
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
A number of the PUBLIC methods of Progress.Lang.Class use classes in the
Progress.Reflect package both as parameters and as a way of returning information.
The "Get" reflection methods return instances of classes to describe class members. For
example, if you call GetMethod( ) to get information about a
particular method of a class, GetMethod( ) returns an
instance of Progress.Reflect.Method representing the method.
The following table describe some of the public properties of Progress.Reflect.Method.
| Property | Description |
|---|---|
AccessMode AS
Progress.Reflect.AccessMode |
Returns an instance of the
built-in enumeration Progress.Reflect.AccessMode
indicating the access mode of the method. |
IsOverride AS
LOGICAL |
Returns TRUE if
the method is an override. |
Name AS
CHARACTER |
Returns the method name. |
OriginatingClass AS Progress.Lang.Class |
Returns an instance of
Progress.Lang.Class representing the class the method was retrieved
from. |
As mentioned in the table, Progress.Reflect.AccessMode is a built-in
enumeration type. For more information about working with ABL enumeration types, see the
ENUM statement entry in ABL
Reference.
Progress.Reflect.Method also provides methods, including an Invoke(
) method (with overrides for both static and instance methods) that allows you to
call the method that the Progress.Reflect.Method instance represents. This is
the syntax for the instance method override:
|
This override takes an instance of the class that implements the method and a parameter list to hold the parameters that are passed to the method.
The following code uses reflection methods to add two pieces of data to a JSON array and then write that array to a file, following these steps:
GetClass( )is invoked statically to createplcjArray, aProgress.Lang.Classinstance representing aProgress.Json.ObjectModel.JsonArrayobject. TheGetConstructor( )method ofProgress.Lang.Classis invoked to createjArray, an instance ofJsonArray.GetMethod( )is invoked onplcjArrayto createmyMethod, an instance ofProgress.Reflect.Method, which in this case represents theAdd( )method ofJsonArray. ThenInvoke( )is called onmyMethod, which invokesAdd( )to add the character data tojArray.- After getting the method again using a revised parameter list,
Invoke( )is called onmyMethodto add the date tojArray. GetMethod( )is invoked again onplcjArray, this time to create an instance ofProgress.Reflect.Methodthat represents theWriteFile( )method ofJsonArray.Invoke( )is called onmyMethodto writejArrayto file.
|
For full descriptions of the properties and methods of
Progress.Reflect.Constructor, Progress.Reflect.Method,
Progress.Reflect.Event, Progress.Reflect.Property, and
Progress.Reflect.Variable, see their entries in ABL Reference.