Retrieve class information without instantiation

Posted by Admin on 04-Nov-2009 08:23

Is there any way to programatically get information about a class that has not been loaded (New'd)?. This would be similar to how the Class Browser shows Member and Inherits information for a class.

For example, I have a form where I would like to see if it's inheriting some base class, but without performing myForm = NEW NameSpace.FormName( ). If the form has been loaded using NEW, I can use the following to get at the information:

DEFINE VARIABLE myType AS System.Type NO-UNDO.

myType = Progress.Util.TypeHelper:GetType("NameSpace.FormName")
     NO-ERROR.

myType:BaseType:ToString( ) returns the class that my form is inheriting.

I'd like to do the same without loading the form.

Thanks!

Jim

All Replies

Posted by Phillip Magnay on 04-Nov-2009 10:41

jim.litzie wrote:

Is there any way to programatically get information about a class that has not been loaded (New'd)?. This would be similar to how the Class Browser shows Member and Inherits information for a class.

For example, I have a form where I would like to see if it's inheriting some base class, but without performing myForm = NEW NameSpace.FormName( ). If the form has been loaded using NEW, I can use the following to get at the information:

DEFINE VARIABLE myType AS System.Type NO-UNDO.

myType = Progress.Util.TypeHelper:GetType("NameSpace.FormName")
     NO-ERROR.

myType:BaseType:ToString( ) returns the class that my form is inheriting.

I'd like to do the same without loading the form.

Thanks!

Jim

Yes, this is reasonably straightforward. You should be able to do this:

DEFINE VARIABLE myClassReference     AS    progress.lang.class    NO-UNDO.

myClassReference = Progress.Lang.Class:GetClass("namespace.FormName").

IF VALID-OBJECT(myClassReference) THEN
    MESSAGE myClassReference:SuperClass:TypeName
    VIEW-AS ALERT-BOX.

Posted by Admin on 04-Nov-2009 10:54

Perfect!!!

Thanks Phillip.

This thread is closed