4

目前,我正在探索添加到 Visual Studio 2010 Beta 1 IDE 中的所有新功能,并找到了一个希望对我有很大帮助的功能。架构版中的 UML 建模工具。我想创建一个新的测试项目,没什么特别的。我开始只创建一个标准的 UML 逻辑类图。然后在我完成后,我想将我的图表导出到带有类存根的 C# 代码,但我不知道该怎么做。所以自然而然地我咨询了 MSDN,但我找不到任何关于自上而下设计方法的参考,并有点放弃了。然后我碰巧在 Channel 9 网站上观看了自上而下的架构视频,他们提到 Visual Studio 2010 能够完成这项任务的可能性。

所以我想我的问题是,Visual Studio 2010 可以采用逻辑类图并从中生成代码存根吗?

我目前在 Windows 7 上使用 Visual Studio 2010 Beta 1 Team System(如果有帮助的话)。

谢谢

4

3 回答 3

4

Try the following topics from the RC docs:

  • How to: Generate Files from a UML Model

    From a UML model, you can generate program code, schemas, documents, resources, and other artifacts of any kind. One convenient method of generating text files from a UML model is to use text templates. These let you embed program code inside the text that you want to generate.

  • Customizing Your Model with Profiles and Stereotypes

    You can adapt the standard UML model elements, such as classes and components, to customize them for specific purposes. You can apply a stereotype to a model element that can change the element's list of properties. Stereotypes are defined within collections called profiles.

You might also check out this blog post by Tim Fischer helps: "How To: Generate Code from Team System UML Diagrams in VS 2010 Team System Beta 2 (Update 4)"

Here is the first code-snippet about how to generate code from UML-Diagrams using T4 Text-Templates.alt text
(source: msdn.com)

Here's another blog post by Oleg Sych: UML Modeling and Code Generation in Visual Studio 2010

Assuming that reader is already familiar with UML, it focuses on custom UML profiles - an extensibility mechanism that can be used to tailor UML models to a particular problem domain. Readers will see an example of such a profile, which extends UML Class Diagrams for database modeling. Finally, the article shows how code can be generated from UML models using T4 text templates.

I've posted more links on my profile for more info.

于 2010-02-18T18:22:52.323 回答
2

您的回答是Visualization and Modeling Feature Pack。这个包为您提供了从 Visual Studio 2010 建模工具等生成代码所需的一切。

于 2010-07-15T20:03:22.353 回答
1

根据 MSFT 的说法,答案是否定的。或者至少,它不是默认内置的,但可以通过扩展提供。看这里

于 2009-10-04T20:21:05.557 回答