.Net Ought To Know #6 : Corillian's product is a "Component Container." Name at least 3 component containers that ship now with the Windows Server Family?
The answer to the question is not that tough so I thought we would go a little deeper and talk about Components, Controls, and Containers Oh My!! (Sorry I couldn't resist). In the .Net Framework, simply put, a component is a class that implements the System.ComponentModel.IComponent interface or derives from a class that does. A component is something that can be reused. C# is considered a component-oriented language. Re-use is everything in component-oriented design. Putting together pre-tested parts is faster and cheaper then coding it yourself. So to summertime, a component is any class that directly or indirectly implements the IComponent Interface. A component can be added to the toolbox and dragged and dropped onto a form.
A control on the other hand is a component that provides a UI. To do this you need to implement System.Windows.Forms.Control OR System.Web.UI.Control. So a control is basically a component that has visual properties.
This finally leads us to the answer to this question. You need a place to hold your components and controls. This is done in a Container. A Container is a class that implements the System.ComponentModel.IContainer interface (directly or indirectly). Since this container holds your controls, it is easy to access the controls dynamically.
9 Private Class ControlWalker
10 Private mContainer As Object
11 Public Sub New(ByVal Container As Object)
12 Dim cControl As Control
13 If Container.haschildren Then
14 For Each cControl In Container.controls
15 'add this control to the controls collection
16 m_controls.Add(cControl)
17 If cControl.HasChildren Then
18 'This control has children, create another
19 'ControlWalk go visit each of them
20 Dim cWalker As New ControlWalker(cControl)
21 End If
22 Next cControl
23 End If
24 End Sub
25 End Class
So you tell me now, this should be easy. What are 3 containers in then Windows Server Family?
Happy Programming.
Doc