System.IDisposable interface realization for custom class in VS 2010 Ultimate UML Editor

孤街浪徒 提交于 2019-12-24 22:22:00

问题


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


回答1:


I discovered to do it as follows:

The clean (slightly overkill) variant:

  • Open Architecture -> Windows -> Architecture Explorer
  • Browse thru to find the class/type you need. In this example Saved DGQL Queries -> All Assembly References → mscorlib.dll → IDisposable
  • Draw IDisprosable onto white ground (The System package will be generated, the IDisposable will be generated inside and all other stuff which is needed from the framework is added to the model tree (but not drawn))
  • Use the smart connector to connect IDisposable element to your entity

The smart way (if you know in which namespace the desired element is placed and how it "looks" like):

  • Open Architecture -> Windows -> Architecture Explorer
  • Right click on "Modelling"
  • Select "Add -> Package".
  • Name it "System"
  • Add an interface underneath and name it "IDisposable"
  • Add an operation "Dispose()"
  • Now you have a dummy.

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.

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.



来源:https://stackoverflow.com/questions/4985818/system-idisposable-interface-realization-for-custom-class-in-vs-2010-ultimate-um

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