Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Pawel Jasinski on February 16, 2012, 10:31:30 pm
-
hi,
is there an api way to obtain list of stereotypes from MDG?
I am trying to avoid reading and parsing of the MDG file parallel to what EA does.
Cheers,
Pawel
-
If you happen to find it out let us know. Somewhere it must be hidden in EA's tables but neither t_stereotypes nor t_xrefs seems to hold that information. There must be some other secret door. (Except they parse each MDG on startup and hold it in local memory.)
q.
-
I think it is in an internal memory table filled at startup. Definetely it is not copied in the internal database i have checked all tables in an empty ea file.
-
So the only way is to find out the loaded MDGs (must be somewhere in the registry since it is user based) and to parse the single XMLs yourself. Does not sound like something for the evening. More like for a couple of long winter nights...
q.
-
A code to save time thats reads a s specific technology file and gets the stereotypes
public void open()
{
// XmlTextReader m_handle = new XmlTextReader(m_technology);
m_xmlDoc = new XmlDocument();
m_xmlDoc.Load(m_technologyName);
m_stereotypeList = new List<Stereotype>();
XmlElement root = m_xmlDoc.DocumentElement;
XmlNodeList profiles = m_xmlDoc.SelectNodes("//UMLProfiles/UMLProfile/Documentation");
foreach (XmlNode profile in profiles)
{
XmlNodeList stereotypes = profile.SelectNodes("../Content/Stereotypes/Stereotype");
//Select Stereotype attribute
foreach (XmlNode stereotype in stereotypes)
{
XmlNode apply = stereotype.SelectSingleNode("./AppliesTo/Apply");
if ((apply != null) && apply.Attributes.GetNamedItem("type").Value == "ToolboxPage") continue;
Stereotype st = new Stereotype();
st.Technology = profile.Attributes.GetNamedItem("name").Value;
st.Name = stereotype.Attributes.GetNamedItem("name").Value;
if (apply != null) st.Apply = apply.Attributes.GetNamedItem("type").Value;
try
{
st.Generalize = stereotype.Attributes.GetNamedItem("generalizes").Value;
}
catch { }
XmlNodeList taggedValues = stereotype.SelectNodes(".//TaggedValues/Tag");
foreach (XmlNode tag in taggedValues)
{
st.taggedValues.Add(tag.Attributes.GetNamedItem("name").Value);
}
m_stereotypeList.Add(st);
}
}
}
public class Stereotype
{
public String Technology;
public ArrayList taggedValues;
public String Name;
public String Apply;
public String Generalize;
public Stereotype()
{
taggedValues = new ArrayList();
}
}
It reads stereotypes and also the tagged values associated to it