Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.ComponentModel namespace usage

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?

like image 914
Ash Avatar asked Dec 15 '09 13:12

Ash


People also ask

What is System ComponentModel?

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.

What is using system ComponentModel DataAnnotations?

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.

Which namespace is used to display data annotations?

The namespace System. ComponentModel. DataAnnotations, has a group of classes, attributes and methods, to make validations in our . NET applications.

What is a component C#?

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.


1 Answers

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:

  • AsyncOperation
  • AsyncOperationManager
  • ProgressChangedEventHandler / ProgressChangedEventArgs
  • RunWorkerCompletedEventHandler / RunWorkerCompletedEventArgs
like image 177
Dave Mateer Avatar answered Sep 27 '22 02:09

Dave Mateer