Is it possible to omit namespaces in VS 2010 Ultimate UML Editor?

南笙酒味 提交于 2019-12-11 17:17:56

问题


when designing UML models in Visual Studio 2010 Ultimate (with Visualization and Modeling Feature Pack 1) I always need to indicate the full Type name (including the namespace) in order to get code that compiles (when doing 'Generate Code...'). Is there a way to "import" namespaces into the model? I can 'Add Reference...' on the Modelling Project, but this won't work because VS puts it as a Layer Reference (which is something else unfortunately).

Being forced to indicate the whole namespace makes the UML diagrams really hard to read... Imagine this being one line in an UML class model:

+ GetTexture(device : Microsoft.Xna.Framework.Graphics.GraphicsDevice) : Microsoft.Xna.Framework.Graphics.Texture2D

Thanks for your help!


回答1:


I figured out it is possible, though not really the best idea.

Open Architecture -> Windows -> UML Model Explorer. Right click on "Modelling" and select "Properties". Expand Stereotypes -> C# namespace and enter all namespaces you wish to have reference in the generated code files ("using ...") under "Using namespace" as a semi-colon separated list.

The better way to do it is described in this post. The reason is that in this case the type is for sure the one you selected and clashes (with other types from other namespaces in the generated code file) cannot occur.



来源:https://stackoverflow.com/questions/4985677/is-it-possible-to-omit-namespaces-in-vs-2010-ultimate-uml-editor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!