是否可以使用分部类来扩展 Dundas 图表控件?
是否可以扩展 Dundas 图表控件或任何其他专有(二进制分布式)控件,而我们没有使用部分类的源?
我以为只要引用了dll就可以完成,但我一直在努力寻找一种方法来做到这一点。
我试图避免创建继承自 Dundas.Charting.WebControl.Chart 类的 ASP .NET 服务器控件。
Is it possible to extend a dundas chart control or any other propietary (binary distributed) control(s) where we don't have the sources using partial classes?
I thought it could be done as long as the dll was referenced, but I've been struggling trying to find a way of doing this.
I'm trying to avoid the creation of an ASP .NET Server Control which inherits from the Dundas.Charting.WebControl.Chart class.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,要使用分部类,该类的主声明必须已经使用了partial 关键字,但通常情况并非如此。
如果类未标记为密封,则可以继承。 你似乎不想要那样,但这可能是最短的路径。
最后一个选项(但始终有效)是将控件嵌入到扩展其功能的包装器中。
No, to use a partial class the main declaration of that class must already use the partial keyword, usually not the case.
Inheritance is possible if the class is not marked as sealed. You seem not to want that, but it could be the shortest path.
The last option, but one that always works, is to embed the control in a Wrapper that extends its functionality.
不,这是不可能的。 所有部分定义必须驻留在同一个程序集中。 您的扩展方法可能是从 Chart 类继承。
Nope, this is not possible. All partials definitions must reside in the same assembly. Your way to extend may be to inherit yourself from the Chart class.
如果该类是密封的,则您无法继承它来添加自己的功能。 如果您使用 .net 3.5,您也可以为您想要添加的类进行类扩展。
如果这些选项都不可行,您将必须创建一个包装类。
if the class is sealed, you cannot inherit from it to add your own functionality. If you are using .net 3.5 you can make class extensions for the class you want to add too.
If neither of these options are viable, you will have to create a wrapper class.