通过 Enterprise Architect 中的 C# 插件进行标记值验证

Tagged value validation through C# add-ins in Enterprise Architect

我正在编写一个 C# 插件 Enterprise Architect 来验证标记值,因为当我使用 Type=Integer 的标记值时默认值 0 出现在标记值 space 中。 我已经给出了 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; 
}

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

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

请提前Help.Thanks。

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

repository.RefreshModelView(element.PackageID)
repository.ShowInProjectView(element)