Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2010 Visual Studio 2010/2012/2013,类图:如何将接口显示为基类,而不是“类”;莉莉波普;?_Visual Studio 2010_Visual Studio 2012_Visual Studio 2013_Visual Studio 2019 - Fatal编程技术网

Visual studio 2010 Visual Studio 2010/2012/2013,类图:如何将接口显示为基类,而不是“类”;莉莉波普;?

Visual studio 2010 Visual Studio 2010/2012/2013,类图:如何将接口显示为基类,而不是“类”;莉莉波普;?,visual-studio-2010,visual-studio-2012,visual-studio-2013,visual-studio-2019,Visual Studio 2010,Visual Studio 2012,Visual Studio 2013,Visual Studio 2019,由于接口已经在图表上,我想显式地显示继承引用。但我找不到如何 到2012年,VS2005中有一个bug不允许它工作。 我周围有一个工作,可能会欺骗它绘制接口的继承。 假设您的接口称为IMyInterface。您必须用实现该接口的抽象类替换它,并使用它而不是您的接口。代码将使用条件编译,如下所示: //to generate class diagram, add 'CLSDIAGRAM' to the conditional symbols on the Build tab, // or add

由于接口已经在图表上,我想显式地显示继承引用。但我找不到如何


到2012年,VS2005中有一个bug不允许它工作。 我周围有一个工作,可能会欺骗它绘制接口的继承。 假设您的接口称为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 //要生成类图,请将“CLSDIAGRAM”添加到“生成”选项卡上的条件符号中, //或在此文件顶部添加“#定义CLSDIAGRAM” #if CLS图 #警告CLSDIAGRAM已定义,此构建仅应在生成类图的上下文中使用 //通过添加_ 公共接口IMyInterface\u { int MyProperty{get;} void MyMethod(); } //此类将充当类图中的接口;) 公共抽象类IMyInterface:IMyInterface\诱使其他代码改用该类 { //伪实现 公共财产{ 获取{抛出新的NotImplementedException();} } 公共方法() { 抛出新的NotImplementedException(); } } #否则 //这是原始接口 公共接口IMyInterface{ int MyProperty{get;} void MyMethod(); } #恩迪夫 这很可能会如你所愿。
在您的情况下,IMyInterface将成为IMedicine。

我也对此感兴趣,但从和其他线程判断,这是不可能的。即使在VS 2012 RC!即使在VS 2013中仍然不起作用“添加对显示类和它实现的接口之间的行的支持是我们未来版本列表中要求最高的功能之一”-MS在2005年表示:)-。我很高兴您在过去4年中一直在编辑这个问题,添加新的visual studio版本。2015年怎么样?幸运吗?谢谢你的回答。当然,我会专门使用一些附加代码来增加设计图的信息量,但对我来说,将其与条件编译结合使用是一件新鲜事。