このコードをUMLクラス図で実行しているので、問題なく動作しますが、Visual StudioのPropertiesEditorから関係の終わり(FirstRoleとSecondRole)にステレオタイプを適用しようとすると、そこにコードがある場合でもステレオタイプコンボが読み込まれませんアソシエーションプロパティに有効な適用可能なステレオタイプのようです。IPropertyを除いて、UMLプロファイルのメタクラスタグに何を入れる必要がありますか?
<metaclassMoniker name="/MyUmlProfile/Microsoft.VisualStudio.Uml.Classes.IProperty"/>
これはコードです:
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 );
}
}
}
}