隐藏继承的成员 [英] Hiding inherited members

查看:129
本文介绍了隐藏继承的成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在找一些方法来有效地隐藏继承的成员。我有从公共基类继承的类的库。近来的一些子类都继承已成为遗迹,并使用时,可以是一个有点混乱依赖属性的智能感知的或者使用一个可视化设计的类。

I'm looking for some way to effectively hide inherited members. I have a library of classes which inherit from common base classes. Some of the more recent descendant classes inherit dependency properties which have become vestigial and can be a little confusing when using IntelliSense or using the classes in a visual designer.

这些类是被写来编译无论是WPF或Silverlight 2.0的所有控件。我知道 ICustomTypeDescriptor ICustomPropertyProvider ,但我pretty某些那些不能在Silverlight中使用。

These classes are all controls that are written to be compiled for either WPF or Silverlight 2.0. I know about ICustomTypeDescriptor and ICustomPropertyProvider, but I'm pretty certain those can't be used in Silverlight.

这不是尽可能多的功能性问题,因为一个可用性问题。我应该怎么办?

It's not as much a functional issue as a usability issue. What should I do?

更新

一些我真的想隐藏来自祖先不属于我自己的,因为一个特定的工具,我设计的,我不能做构件与新隐藏属性运营商。 (我知道,这是荒谬的)

Some of the properties that I would really like to hide come from ancestors that are not my own and because of a specific tool I'm designing for, I can't do member hiding with the new operator. (I know, it's ridiculous)

推荐答案

覆盖它们像迈克尔:建议上述< / A>,并从使用覆盖prevent乡亲方法,它们标记为过时(SP):

Override them like Michael Suggests above and to prevent folks from using the overridden (sp?) methods, mark them as obsolete:

[Obsolete("These are not supported in this class.", true)]
public override  void dontcallmeanymore()
{
}

\r
\r

如果第二PARM设置为true,将产生一个编译错误,如果有人试图调用该方法,并在第一个PARM该字符串的邮件。如果parm2是假的只是将产生编译器警告。

If the second parm is set to true, a compiler error will be generated if anyone tries to call that method and the string in the first parm is the message. If parm2 is false only a compiler warning will be generated.

这篇关于隐藏继承的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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