Dynamics AX 2012:如何通过代码获取特定窗体中所有方法的列表?



有什么方法可以通过代码获取 Dynamics AX 2012 中给定形式中所有方法的列表?

我正在努力开发一个小工具,该工具将使用 Editor 类在自定义对象的所有方法中插入一些注释。但是,要做到这一点,我需要每个方法的完整路径(例如:\Classes\MyClass\CustomMethod),但我根本找不到任何方法可以让它适用于表单。

提前感谢!

感谢您向我发送建议。实际上,我刚刚编写了一些代码来获取信息。这是代码,适合任何可能感兴趣的人:

//I used the BatchJobHistory form as a test, since I called this static method from a job
public static void findAllChildNodes(str _nodeName = "\Forms\BatchJobHistory", boolean _isMethod = NoYes::No)
{
TreeNode         treeNode;
TreeNodeIterator treeNodeIterator;
treeNode         methodsNode;
str              treePath;
boolean          containsMethod;
treeNode = TreeNode::findNode(_nodeName);
treeNodeIterator = treeNode.AOTiterator();
methodsNode = treeNodeIterator.next();
while(methodsNode)
{
treePath = methodsNode.treeNodePath();
containsMethod = strScan(treePath, 'Methods', 1, strLen(treePath));
if (methodsNode.AOTchildNodeCount())
{
//TestClass is the class containing this method
TestClass::findAllChildNodes(treePath, containsMethod);
}
else if (_isMethod)
{
info(strFmt("%1", treePath));
}
methodsNode = treeNodeIterator.next();
}
}

这是一个应该为你指明正确方向的问题,尽管你需要扩展它。

AX2009 循环访问初始化时窗体中的所有控件

您可能需要处理的一般主题是recursion(https://en.wikipedia.org/wiki/Recursion_(computer_science))、reflection以及使用该类的TreeNode和派生来执行Tree Node Traversal(https://en.wikipedia.org/wiki/Tree_traversal)

请参阅 https://learn.microsoft.com/en-us/dynamicsax-2012/developer/performing-reflection-with-the-treenode-class

我还在想象,如果您尝试使用注释来装饰方法,则需要使用一些层感知方法。这听起来很有趣,但有点痛苦。我预计至少需要半天才能正常工作。

最新更新