Rom*_*kij 17 visual-studio-2010 visual-studio-2012 visual-studio-2013 visual-studio-2019
由于接口已经在图表上,我想明确地显示继承引用.但是我找不到......

VS 2005到2012年有一个错误,它不允许它工作.我有一个工作arround可能会欺骗它绘制接口的继承.假设您的界面名为IMyInterface.您必须将其替换为实现该接口的抽象类,并使用它而不是您的接口.代码将使用条件编译,如下所示:
//to generate class diagram, add 'CLSDIAGRAM' to the conditional symbols on the Build tab,
// or add '#define CLSDIAGRAM' at the top of this file
#if CLSDIAGRAM
#warning CLSDIAGRAM is defined and this build should be used only in the context of class diagram generation
//rename your interface by adding _
public interface IMyInterface_
{
int MyProperty { get; }
void MyMethod();
}
//this class will act as an interface in the class diagram ;)
public abstract class IMyInterface : IMyInterface_ // tricks other code into using the class instead
{
//fake implementation
public int MyProperty {
get { throw new NotImplementedException(); }
}
public void MyMethod()
{
throw new NotImplementedException();
}
}
#else
// this is the original interface
public interface IMyInterface {
int MyProperty { get; }
void MyMethod();
}
#endif
这可能会按照您的意愿显示出来.在您的情况下,IMyInterface将成为IMedicine.
| 归档时间: |
|
| 查看次数: |
3249 次 |
| 最近记录: |