我想使用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.
}
}
}
}
我花了很多时间来找到方法的动作类型,但还没有找到它。
答案 0 :(得分:1)
mt.returntype
可以是do
,entry
或exit
。