Domanda

Io corro questo codice su una classe diagramma UML, e funziona bene, ma quando si cerca di applicare stereotipi da PropertiesEditor in Visual Studio per la relazione finisce (FirstRole e SecondRole), il combo stereotipi non caricare, anche se nel codice ci sembra essere stereotipi applicabili validi per le proprietà di associazione. Che cosa devo mettere in tag metaclassi nel profilo UML ad eccezione di iProperty?

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

Questo è il codice:

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 );
            }
        }
    }
}
È stato utile?

Soluzione

ho postato questa domanda a Blog di Skinner e ho ottenuto questa risposta:

  

"Purtroppo, questo è un bug nel nostro codice."

Una soluzione dovrebbe venire con Visual Studio 2010 SP1.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top