通过Enterprise Architect中的C#加载项进行标记值验证

时间:2016-11-09 12:19:01

标签: c# add-in enterprise-architect

我正在编写一个C#Add-in Enterprise Architect来验证标记值,因为当我使用Type = Integer的标记值时,标记值空间中会出现默认值0。 我给出了Type = String的标记值并验证了用户输入的值。我使用以下代码。

    public bool EA_OnNotifyContextItemModified(EA.Repository Repository, string GUID, EA.ObjectType ot)
        {


                string test_value;
                bool isInteger;
                int integer_converted;
                if (ot == EA.ObjectType.otElement)
                {

                        EA.Element element = (EA.Element)Repository.GetElementByGuid(GUID);
                        EA.TaggedValue tag = element.TaggedValues.GetByName("MAX-BASE-TYPE-SIZE");
                        test_value = tag.Value;
                        if (string.IsNullOrEmpty(test_value))
                        {
                            Session.Repository.WriteOutput("EA", "Enter any Value", 1);
                        }
                        else
                        {
                            isInteger = int.TryParse(test_value, out integer_converted);
                            if (isInteger == false)
                            {

                                string empty = " ";
                                tag.Value = empty;
                                tag.Update();
                                Session.Repository.WriteOutput("EA", "Enter Integer Value" + " " + tag.Name + ":" + "", 1);
                            }
                        }
                    }

                }
            }


            return true; 
}

问题是,只有当我关闭元素属性窗口并重新打开元素时才会用空字符串替换无效的标记值。

当我将光标移动到元素本身的下一个标记值而不是每次关闭并重新打开元素时,如何查看使用空字符串更新的标记值。

请帮助。谢谢。

1 个答案:

答案 0 :(得分:0)

没有优雅的解决方案。您需要刷新模型视图并再次在浏览器中显示元素,如(伪代码):

repository.RefreshModelView(element.PackageID)
repository.ShowInProjectView(element)
相关问题