VS 2010 Ultimate UML Editor中自定义类的System.IDisposable接口实现 [英] System.IDisposable interface realization for custom class in VS 2010 Ultimate UML Editor

查看:21
本文介绍了VS 2010 Ultimate UML Editor中自定义类的System.IDisposable接口实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计了一个类(在 UML 中),它应该实现 System.IDisposable 接口.我该怎么做才能在生成代码时正确识别它,而不必绘制我自己的系统"包,其中包含一些IDisposable"接口?

I have designed a class (in UML) which should implement the System.IDisposable interface. How do I do it so that when generating code it get's recognized properly and withou having to draw my own "System" package with some "IDisposable" interface in it?

感谢您的帮助!干杯,大卫

Thanks for your help! Cheers, David

推荐答案

我发现这样做如下:

干净(有点矫枉过正)变体:

  • 开放架构 -> Windows -> 架构资源管理器
  • 浏览以找到您需要的类/类型.在这个例子中,保存的 DGQL 查询 -> 所有程序集引用 → mscorlib.dll → IDisposable
  • 将 IDisprosable 绘制到白色地面上(将生成 System 包,将在内部生成 IDisposable 并将框架中需要的所有其他内容添加到模型树中(但未绘制)
  • 使用智能连接器将 IDisposable 元素连接到您的实体

聪明的方法(如果您知道所需元素放置在哪个命名空间以及它的外观"如何):

  • 开放架构 -> Windows -> 架构资源管理器
  • 右键单击建模"
  • 选择添加 -> 包".
  • 将其命名为系统"
  • 在下面添加一个接口并将其命名为IDisposable"
  • 添加操作Dispose()"
  • 现在你有了一个假人.

如果你想给一个应该是 IDisposable 的类添加一个属性,你可以选择该属性的属性类型"(属性窗口)为 Modelling::System::IDisposable.

Say if you want to add an attribute to a class that should be of IDisposable, you can select the attribute's property "Type" (Properties window) to be Modelling::System::IDisposable.

在生成代码"方面,我发现将我自己的所有建模类放入一个包中,这样它就可以与 System.然后您可以简单地(而不是右键单击白色地面并选择生成代码"以生成所有人工制品的代码)右键单击您的包并选择生成代码",它将仅为您的包生成代码,而不是系统的东西(假人).如果您在模型中很好地设置了命名空间,就像 这篇文章.

In term of "Generating code" I found it clever to place all of my own modelled classes into a package so that it becomes separated from the packages like System. Then you can simply (instead of right clicking on white ground and selecting "Generate code" in order to generate code for all artefacts) right click on your package and select "Generate code" and it will generate code just for your package and not the System stuff (dummies). It becomes valid either way if you have the namespaces set nicely in your model like described in this post.

这篇关于VS 2010 Ultimate UML Editor中自定义类的System.IDisposable接口实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆