![]() |
#1 |
Участник
|
gatesasbait: Code code to generate code in Dynamics AX
Источник: http://gatesasbait.spaces.live.com/B...B9F5!240.entry
============== Good morning, The following job will create a new static method on the SalesLine table at runtime. Use it as a tutorial for TreeNodes' AOTadd(), AOTsetSource(), AOTcompile() and AOTfindChild() methods. Note that access to such code should be restricted through security keys, namely the 'SysDevelopment' key since this code definitely uses a dangerous API. X++: public static void createMethodTest(Args _args) { #AOT #define.myNewStaticMethod('myNewStaticMethod') #define.methods('methods') parentNode; methodNode; MemberFunction subMethodNode; sysDictTable = new SysDictTable(tablenum(SalesLine)); Source = "public static void myNewStaticMethod()\n" + "{\n" + " ;\n" + " info(\"test\");\n" + "}\n"; ; if (hasSecuritykeyAccess( securitykeynum(SysDevelopment), AccessType::Delete)) { parentNode = TreeNode::findNode(#TablesPath+'\\'+sysDictTable.name()); if (parentNode) { methodNode = parentNode.AOTfindChild(#methods); subMethodNode = methodNode.AOTfindChild(#myNewStaticMethod); if (!subMethodNode) { subMethodNode = methodNode.AOTadd(#myNewStaticMethod); } subMethodNode.AOTsetSource(source, true); //true sets 'static' parentNode.AOTcompile(); } } } ![]() ![]() Источник: http://gatesasbait.spaces.live.com/B...B9F5!240.entry
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|