System.ComponentModel 命名空间使用
我认为自己是一位相当有经验的 .NET 开发人员,但我几乎从未直接使用过 System.ComponentModel 命名空间中的类型。 (我已经实现了一些自定义属性并通过反射使用它们)。
Component、Container、PropertyDescriptor、TypeDescriptor、License 和 TypeConverter 等类型在什么情况下最有用?
在谈论“设计器”(例如 Visual Studio 中可用的设计器)时,我经常看到 System.ComponentModel 被提及。
这些类型是否仅在您想要使用漂亮的视觉设计器(例如自定义属性等)构建自定义控件时才有用?或者我也可以在更通用的代码中使用它们吗?
I consider myself a reasonably experienced .NET developer but I have almost never directly used types in the System.ComponentModel namespace. (I've implemented a few custom attributes and consumed them via reflection).
In what sort of scenarios do types such as Component, Container, PropertyDescriptor, TypeDescriptor, License and TypeConverter come in most useful?
I've often seen System.ComponentModel mentioned when talking about "designers" such as those available in Visual Studio.
Are these types only useful when you, for example, want to build a custom control with nice visual designer (eg. custom properties etc)? Or could I also be using them in more general code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
和您一样,我只间接使用了您列出的特定类(
Component
、Container
等),即以已经派生的形式(每个System. Windows.Forms.Control
派生自Component
等)。所以我没有什么要补充的。向自定义控件添加属性时,我几乎总是使用许多DefaultValueAttribute
、DesignerSerializationVisibilityAttribute
和其他*Attribute
类。但这很常见,而且可能不是你的问题所在。至于命名空间的其余部分,我需要大量异步处理,并经常使用以下内容:
Like you, I've only used the specific classes you list (
Component
,Container
, etc.) indirectly, i.e. in already-derived form (everySystem.Windows.Forms.Control
derives fromComponent
, etc.). So I don't have anything more to add there. When adding properties to custom controls, I almost always use many of theDefaultValueAttribute
,DesignerSerializationVisibilityAttribute
, and other*Attribute
classes. But that's pretty common, and probably not what your question was after.As far as the rest of the namespace, I have need for a lot of asynchronous processing, and make frequent use of the following: