[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.axapta.programming

Getting method signatures from system classes

Lars K. Schunk

11/11/2005 8:52:00 PM

Hey all,

I'm doing a little X++ programming project to learn Axapta. I run through
the Classes node in the AOT, and then generate a web page for each class,
where I syntax highlight and categorize all the methods based on access
specifiers and static/not static specifiers. I do this by passing
mf.AOTgetSource() to a new ScannerClass object (mf is a MemberFunction
object), and then scanning the signature of the method.

Now to the problem: I want to do the same thing with all the system classes
(System Documentation\Classes in the AOT). I can't use AOTgetSource because
the source code is not available for these classes. However, the method
signature is shown in the status bar and in the Help, e.g.
KERNDOC://Classes/Args/dataset. Is there any way I can fetch this signature
from X++ so that I can pass it to the ScannerClass?

Another solution I have tried is to use SysMethodInfo, and then get various
information from methods such as accessSpecifier() and isStatic(). This way
I can get most of the information I need, including the number of parameters
and the types of each parameter, but apparently I can't get the parameter
names, which I need.

Hope some one can help :-)

Cheers,
Lars


5 Answers

Mike Frank

11/14/2005 8:20:00 AM

0

You can use the (Sys)MethodInfo class for that.

SysMethodInfo methodInfo = new SysMethodInfo(UtilElementType::ClassInstanceMethod,
classnum(BinaryIO), 'finalize');
;
info(strfmt("%1", methodInfo.accessSpecifier()));

If it were not for an educational project you should use that for the 'regular' classes as well
instead of parsing.

Mike

Lars K. Schunk

11/14/2005 9:58:00 PM

0

Hi Frank,

Thanks for your reply. I need the exact signature, like this, for example
(from SysListPanel):

private int panel_separator_mouseDown(int x, int y, int button, Boolean
Ctrl, Boolean Shift)

With SysMethodInfo, I can get the access specifier, the return type, and the
parameter types -- but not the parameter names, like x, y, button, Ctrl, and
Shift. Or am I missing something?

Lars



"Mike Frank" <mifra@nospam.de> wrote in message
news:uLJTdPP6FHA.1148@tk2msftngp13.phx.gbl...
> You can use the (Sys)MethodInfo class for that.
>
> SysMethodInfo methodInfo = new
> SysMethodInfo(UtilElementType::ClassInstanceMethod, classnum(BinaryIO),
> 'finalize');
> ;
> info(strfmt("%1", methodInfo.accessSpecifier()));
>
> If it were not for an educational project you should use that for the
> 'regular' classes as well instead of parsing.
>
> Mike


Patrick Bovens

11/17/2005 9:05:00 AM

0

Have a look at this code, it may help you getting started. You will be able
to pull most of the info out of the methods, even stuff like variables etc.
This code will only show object methods, but it's easily updated to list
static methods too.

Cheers,

--
Patrick Bovens (Promentum BV / MBS Denmark)

------------------------------------------------------------------------------------

static void ListParameters(Args _args)
{
DictClass dictClass;
DictMethod dictMethod;

int dictObjectMethodIdx;
int parameterIdx;

;

dictClass = new DictClass(classnum(AxdSalesOrder));

if (dictClass)
{
for (dictObjectMethodIdx = 1; dictObjectMethodIdx <=
dictClass.objectMethodCnt(); dictObjectMethodIdx++)
{
dictMethod = dictClass.objectMethodObject(dictObjectMethodIdx);

info(strFmt('Method name: %1', dictMethod.name()));

for (parameterIdx = 1; parameterIdx <=
dictMethod.parameterCnt(); parameterIdx++)
{
info(strFmt('Parameter %1 is of type %2',
dictMethod.parameterName(parameterIdx),
dictMethod.parameterType(parameterIdx)));
}
}
}
}



"Lars K. Schunk" wrote:

> Hi Frank,
>
> Thanks for your reply. I need the exact signature, like this, for example
> (from SysListPanel):
>
> private int panel_separator_mouseDown(int x, int y, int button, Boolean
> Ctrl, Boolean Shift)
>
> With SysMethodInfo, I can get the access specifier, the return type, and the
> parameter types -- but not the parameter names, like x, y, button, Ctrl, and
> Shift. Or am I missing something?
>
> Lars
>
>
>
> "Mike Frank" <mifra@nospam.de> wrote in message
> news:uLJTdPP6FHA.1148@tk2msftngp13.phx.gbl...
> > You can use the (Sys)MethodInfo class for that.
> >
> > SysMethodInfo methodInfo = new
> > SysMethodInfo(UtilElementType::ClassInstanceMethod, classnum(BinaryIO),
> > 'finalize');
> > ;
> > info(strfmt("%1", methodInfo.accessSpecifier()));
> >
> > If it were not for an educational project you should use that for the
> > 'regular' classes as well instead of parsing.
> >
> > Mike
>
>
>

Lars K. Schunk

11/17/2005 8:53:00 PM

0

Hello Patrick,

The parameterName thing doesn't seem to work.

dictMethod.parameterName(parameterIdx)

This function, parameterName, does not exist in my system. Axapta 3.0 SP3.

Lars



"Patrick Bovens (MSFT)" <PatrickBovensMSFT@discussions.microsoft.com> wrote
in message news:6EB6C76C-C9E3-4EDF-AC72-F1C898F67EB0@microsoft.com...
> Have a look at this code, it may help you getting started. You will be
> able
> to pull most of the info out of the methods, even stuff like variables
> etc.
> This code will only show object methods, but it's easily updated to list
> static methods too.
>
> Cheers,
>
> --
> Patrick Bovens (Promentum BV / MBS Denmark)
>
> ------------------------------------------------------------------------------------
>
> static void ListParameters(Args _args)
> {
> DictClass dictClass;
> DictMethod dictMethod;
>
> int dictObjectMethodIdx;
> int parameterIdx;
>
> ;
>
> dictClass = new DictClass(classnum(AxdSalesOrder));
>
> if (dictClass)
> {
> for (dictObjectMethodIdx = 1; dictObjectMethodIdx <=
> dictClass.objectMethodCnt(); dictObjectMethodIdx++)
> {
> dictMethod = dictClass.objectMethodObject(dictObjectMethodIdx);
>
> info(strFmt('Method name: %1', dictMethod.name()));
>
> for (parameterIdx = 1; parameterIdx <=
> dictMethod.parameterCnt(); parameterIdx++)
> {
> info(strFmt('Parameter %1 is of type %2',
> dictMethod.parameterName(parameterIdx),
> dictMethod.parameterType(parameterIdx)));
> }
> }
> }
> }
>
>
>
> "Lars K. Schunk" wrote:
>
>> Hi Frank,
>>
>> Thanks for your reply. I need the exact signature, like this, for example
>> (from SysListPanel):
>>
>> private int panel_separator_mouseDown(int x, int y, int button, Boolean
>> Ctrl, Boolean Shift)
>>
>> With SysMethodInfo, I can get the access specifier, the return type, and
>> the
>> parameter types -- but not the parameter names, like x, y, button, Ctrl,
>> and
>> Shift. Or am I missing something?
>>
>> Lars
>>
>>
>>
>> "Mike Frank" <mifra@nospam.de> wrote in message
>> news:uLJTdPP6FHA.1148@tk2msftngp13.phx.gbl...
>> > You can use the (Sys)MethodInfo class for that.
>> >
>> > SysMethodInfo methodInfo = new
>> > SysMethodInfo(UtilElementType::ClassInstanceMethod, classnum(BinaryIO),
>> > 'finalize');
>> > ;
>> > info(strfmt("%1", methodInfo.accessSpecifier()));
>> >
>> > If it were not for an educational project you should use that for the
>> > 'regular' classes as well instead of parsing.
>> >
>> > Mike
>>
>>
>>


Patrick Bovens

11/18/2005 11:26:00 AM

0

I'm sorry, guess this is only available in Ax40.

--
Patrick Bovens (MBS Denmark)


"Lars K. Schunk" wrote:

> Hello Patrick,
>
> The parameterName thing doesn't seem to work.
>
> dictMethod.parameterName(parameterIdx)
>
> This function, parameterName, does not exist in my system. Axapta 3.0 SP3.
>
> Lars
>
>
>
> "Patrick Bovens (MSFT)" <PatrickBovensMSFT@discussions.microsoft.com> wrote
> in message news:6EB6C76C-C9E3-4EDF-AC72-F1C898F67EB0@microsoft.com...
> > Have a look at this code, it may help you getting started. You will be
> > able
> > to pull most of the info out of the methods, even stuff like variables
> > etc.
> > This code will only show object methods, but it's easily updated to list
> > static methods too.
> >
> > Cheers,
> >
> > --
> > Patrick Bovens (Promentum BV / MBS Denmark)
> >
> > ------------------------------------------------------------------------------------
> >
> > static void ListParameters(Args _args)
> > {
> > DictClass dictClass;
> > DictMethod dictMethod;
> >
> > int dictObjectMethodIdx;
> > int parameterIdx;
> >
> > ;
> >
> > dictClass = new DictClass(classnum(AxdSalesOrder));
> >
> > if (dictClass)
> > {
> > for (dictObjectMethodIdx = 1; dictObjectMethodIdx <=
> > dictClass.objectMethodCnt(); dictObjectMethodIdx++)
> > {
> > dictMethod = dictClass.objectMethodObject(dictObjectMethodIdx);
> >
> > info(strFmt('Method name: %1', dictMethod.name()));
> >
> > for (parameterIdx = 1; parameterIdx <=
> > dictMethod.parameterCnt(); parameterIdx++)
> > {
> > info(strFmt('Parameter %1 is of type %2',
> > dictMethod.parameterName(parameterIdx),
> > dictMethod.parameterType(parameterIdx)));
> > }
> > }
> > }
> > }
> >
> >
> >
> > "Lars K. Schunk" wrote:
> >
> >> Hi Frank,
> >>
> >> Thanks for your reply. I need the exact signature, like this, for example
> >> (from SysListPanel):
> >>
> >> private int panel_separator_mouseDown(int x, int y, int button, Boolean
> >> Ctrl, Boolean Shift)
> >>
> >> With SysMethodInfo, I can get the access specifier, the return type, and
> >> the
> >> parameter types -- but not the parameter names, like x, y, button, Ctrl,
> >> and
> >> Shift. Or am I missing something?
> >>
> >> Lars
> >>
> >>
> >>
> >> "Mike Frank" <mifra@nospam.de> wrote in message
> >> news:uLJTdPP6FHA.1148@tk2msftngp13.phx.gbl...
> >> > You can use the (Sys)MethodInfo class for that.
> >> >
> >> > SysMethodInfo methodInfo = new
> >> > SysMethodInfo(UtilElementType::ClassInstanceMethod, classnum(BinaryIO),
> >> > 'finalize');
> >> > ;
> >> > info(strfmt("%1", methodInfo.accessSpecifier()));
> >> >
> >> > If it were not for an educational project you should use that for the
> >> > 'regular' classes as well instead of parsing.
> >> >
> >> > Mike
> >>
> >>
> >>
>
>
>