How to apply stereotypes in custom names of UML relationships?

I run this code in the UML class diagram, and it works fine, but when I try to apply the stereotypes from PropertiesEditor in Visual Studio to end the relationship (FirstRole and SecondRole), the combo stereotypes do not load, even if the stereotypes that apply to the code seem to apply association properties. What should I put in metaclasses in a UML profile other than IProperty?

<metaclassMoniker name="/MyUmlProfile/Microsoft.VisualStudio.Uml.Classes.IProperty"/> 

This is the code:

 using Microsoft.VisualStudio.Uml.Classes; foreach( IShape shape in currentDiagram.GetSelectedShapes<IElement>() ) { IElement element = shape.GetElement(); foreach( IStereotype stereotype in element.ApplicableStereotypes ) { if( element is Microsoft.VisualStudio.Uml.Classes.IClass ) { IClass classItem = (IClass)element; if( classItem.SuperClasses.Count() > 0 ) { if( stereotype.Name == "SubclassAttribute" ) { element.ApplyStereotype( stereotype ); } } else if( stereotype.Name == "ClassAttribute" ) { element.ApplyStereotype( stereotype ); } } else if( element is Microsoft.VisualStudio.Uml.Classes.IProperty ) { IProperty property = (IProperty)element; if( property.Association != null ) { if( stereotype.Name == "SetAttribute" && property.UpperValue != null && property.UpperValue.ToString() == "*" ) { element.ApplyStereotype( stereotype ); } else if( stereotype.Name == "ManyToOneAttribute" && ( property.UpperValue == null || property.UpperValue.ToString() == "1" ) ) { element.ApplyStereotype( stereotype ); } } else if( stereotype.Name == "PropertyAttribute" ) { element.ApplyStereotype( stereotype ); } } } } 
+4
source share
1 answer

I posted this question on Skinner Blog and I got this answer:

"Unfortunately, this is a mistake in our code."

The solution should ship with Visual Studio 2010 SP1.

+1
source

Source: https://habr.com/ru/post/1303950/


All Articles