4

このコードを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 );
            }
        }
    }
}
4

1 に答える 1

1

この質問をSkinnerのブログに投稿したところ、次の回答が得られました。

「残念ながら、これはコードのバグです。」

ソリューションは、Visual Studio2010SP1に付属している必要があります。

于 2011-04-22T12:08:03.247 に答える