问题描述
您好,
我想创建一个描述用户定义类型的.cd文件,而不仅仅是类或接口,假设我已经创建了一个名为system的类,现在我正在创建这个类的一些实例。在类图中,我希望看到每个实例的名称
和类型"system"。可能吗? (我正在创建实际描述.cd的XML文件)
I would like to create a .cd file describing user defined types instead of just class or interface, lets say i have created a class called system, now i'm creating some instances of this class. in the class diagram i would like to see the name of each instance and as the type "system" is it possible? (i'm creating the XML file describing the .cd pragmatically)
推荐答案
您可以输出XML,使每个实例显示为单独的"类型"但是,用户体验会让人感到困惑,因为它仍然看起来像一个类图,所以对于用户而言,他们正在查看实例而不是类型的
并不明显。此外,类设计师针对当前解决方案中的代码进行往返,并将标记任何"类型"。它找不到红色十字架,这可能不是你想要的,因为你的所有伪类型都会以这种方式标记。
You might be able to output XML such that each of your instances appears as a separate "type", but the user experience will be confusing as it will still look like a class diagram so it won't be obvious to the user that they are looking at instances rather than types. Also, the Class Designer round-trips against the code in the current solution and will mark any "types" it can't find with red crosses, which probably isn't what you want since all of your pseudo-types would be marked in this way.
如果你想显示实例那么你就是  ;真的需要一个对象图。不幸的是,Visual Studio UML工具也不生成对象图,但是有第三方工具可以做(虽然我不熟悉它们中的任何一个)。或者,
如果您尝试生成的图表不需要复杂的视觉效果(即它是一个简单的框和线图),您可以生成DGML,而Visual Studio将为您呈现图表。如果您需要更复杂的视觉效果,那么您可以使用DSL工具获得自己的
DSL,但除非您已熟悉DSL工具,否则这将会有更多工作。
If you want to show instances then you really need an object diagram. Unfortunately, the Visual Studio UML tools don't produce object diagrams either, but there are third party tools that do (although I'm not familiar with any of them). Alternatively, if the diagram you are trying to produce doesn't need complex visuals (i.e. it is a simple box and line diagram), you could generate DGML instead which Visual Studio will render as a diagram for you. If you need more complex visuals then you could your own DSL using the DSL Tools, but this would be a lot more work unless you are already familiar with the DSL Tools.
问候,
Duncan
这篇关于用户定义的类型类图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!