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?
The System. ComponentModel namespace provides classes that are used to implement the run-time and design-time behavior of components and controls. This namespace includes the base classes and interfaces for implementing attributes and type converters, binding to data sources, and licensing components.
Data annotations (available as part of the System. ComponentModel. DataAnnotations namespace) are attributes that can be applied to classes or class members to specify the relationship between classes, describe how the data is to be displayed in the UI, and specify validation rules.
The namespace System. ComponentModel. DataAnnotations, has a group of classes, attributes and methods, to make validations in our . NET applications.
A component is a class with cleanup and containment. A component can be hosted in a container, and has the ability to query and get services from its container. Containment is logical and does not have to be visual. These components can be deployed in middle tier container as business components.
Like you, I've only used the specific classes you list (Component
, Container
, etc.) indirectly, i.e. in already-derived form (every System.Windows.Forms.Control
derives from Component
, etc.). So I don't have anything more to add there. When adding properties to custom controls, I almost always use many of the DefaultValueAttribute
, 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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With