rashmi rashmi - 29 days ago 15
C# Question

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

I am writing a C# Add-in Enterprise Architect to validate tagged value because a default 0 appears in the tagged value space when I use tagged value of Type=Integer.
I have given tagged value of Type=String and validating the user entered value. I am using the following code.

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;
}


The problem is,the replacement of invalid tagged value with empty string happens only when I close the element properties window and reopen the element.

How to view the tagged value updated with empty string when I move the cursor to the next tagged value of the element itself instead of closing and reopening the element everytime.

Kindly Help.Thanks in advance.

Answer

There is no elegant solution. You need to refresh the model view and show the element in the browser again like (pseudo code):

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