首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在关系的MemberEnds上应用构造型?

如何在关系的MemberEnds上应用构造型?
EN

Stack Overflow用户
提问于 2010-03-13 00:04:46
回答 1查看 745关注 0票数 4

我在一个UML上运行这段代码,它工作得很好,但是当尝试将来自Visual Studio中的PropertiesEditor的构造型应用于关系结束(FirstRole和SecondRole)时,构造型组合不会加载,即使在代码中似乎有适用于关联属性的构造型有效。除了IProperty之外,我应该在UML profile的元类标签中放些什么?

代码语言:javascript
复制
<metaclassMoniker name="/MyUmlProfile/Microsoft.VisualStudio.Uml.Classes.IProperty"/>

代码如下:

代码语言:javascript
复制
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 );
            }
        }
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-04-22 20:08:03

我把这个问题发到了Skinner's Blog上,得到的答案是:

“不幸的是,这是我们代码中的一个错误。”

一个解决方案应该与Visual Studio2010 SP1一起提供。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2433970

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档