我想使用 Enterprise Architect (EA) 的自动化接口根据我公司的 StateMachine 框架从我的 StateMachine 图生成代码。
对于每个状态,我想确切地知道它的操作是进入或退出动作。有关更多详细信息,请参阅图像。
我使用下面的代码片段(C#)来获取方法的动作类型,但它似乎没有办法做到这一点。
private void getElement(EA.Repository repository)
{
//repository.OpenDiagram(6);
EA.Diagram currentDiagram = repository.GetCurrentDiagram();
var objs = currentDiagram.DiagramObjects;
for (short obj_i = 0; obj_i < objs.Count; ++obj_i )
{
EA.Element elem = repository.GetElementByID(objs.GetAt(obj_i));
if(elem.Name == "State") //get only the state elments
{
var stateMethodList = elem.Methods;
for(short mt_i = 0; mt_i < stateMethodList.Count; ++mt_i)
{
EA.Method mt = stateMethodList.GetAt(mt_i);
EA.Parameter parameter = mt.Parameters.GetAt(index); //we can get the method's parameters using the EA.Method.Parameters attribute
string returnType = mt.ReturnType; //we can get the method's return type using EA.Method.ReturnType attribute
//I want to get method's action type but the mt seems to be the common method type, and have no attribute name EA.Method.Actions and something like that.
}
}
}
}
我花了很多时间寻找方法的动作类型,但还没有找到。