关于EA插件中ActivityParameter的Type与Direction获取问题
解决EA插件中ActivityParameter的Type和Direction属性获取问题
EA中的ActivityParameter本质上对应API的Parameter对象,而非普通的Element类型——这就是你通过GetElementByID/GetElementByGuid获取元素后看不到Type和Direction的核心原因。直接通过Parameter对象就能获取这两个属性,具体操作如下:
将Element转换为Parameter对象
先通过Element ID拿到对应的ActivityParameter元素,再用Repository.GetParameterByID()方法获取真正的Parameter实例:// 获取ActivityParameter对应的Element Element activityParamElement = Repository.GetElementByID(yourParamElementId); // 转为Parameter对象 Parameter activityParam = Repository.GetParameterByID(activityParamElement.ElementID);直接访问Type和Direction属性
拿到Parameter对象后,可直接读取所需属性:string paramType = activityParam.Type; string paramDirection = activityParam.Direction; // 值为In/Out/InOut等从Element对象直接获取Type的替代方案
如果需要从已有的Element对象中读取Type,可直接访问其Pdata1属性(对应你SQLQuery中看到的Pdata1字段值):string typeFromElement = activityParamElement.Pdata1;
需要注意:Direction属性仅存储在Parameter对象中,无法从Element对象直接获取,也不会出现在t_object表字段里,必须通过Parameter对象或关联查询t_objectparameters表(关联t_object的Object_ID)才能拿到。
内容的提问来源于stack exchange,提问作者Ice
相关产品推荐
相关产品推荐

