views:

147

answers:

1

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?

+1  A: 

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
Dave
For asynchronous processing I've actually used the Async Programming Model ie. delegates and BeginInvoke(), EndInvoke(). How do AsyncOperation etc differ, do you know?
Ash
When you are creating a class that exposes asynchronous events you typically use AsyncOperation, etc. In other words, when you are the provider of asynchronous events, not the consumer. If you create a class with DoWorkAsync() and CancelAsync() methods, and DoWorkCompleted and DoWorkProgressUpdated events, you might use these to make sure events are invoked on the correct thread.
Dave