2 // System.ComponentModel.Container.cs
5 // Miguel de Icaza (miguel@ximian.com)
7 // (C) Ximian, Inc. http://www.ximian.com
10 namespace System.ComponentModel {
13 // Container class: encapsulates components.
19 public class Container : IContainer, IDisposable {
20 ComponentCollection cc;
23 // Auxiliary class to support the default behaviour of CreateSite
27 // This is an internal class that is used to provide a
28 // default implementation of an ISite class. Container
29 // is just a default implementation of IContainer, and
30 // provides this as a way of getting started
33 class DefaultSite : ISite {
38 public DefaultSite (string name, IComponent component, IContainer container)
40 this.component = component;
41 this.container = container;
45 public IComponent Component {
51 public IContainer Container {
58 public bool DesignMode {
60 // FIXME: should we provide a way to set
77 public virtual object GetService (Type t)
79 // FIXME: do not know what this is supposed to do.
85 // Container constructor
91 public virtual ComponentCollection Components {
98 // Adds an IComponent to the Container
101 public virtual void Add (IComponent component)
103 // FIXME: Add this component to the ComponentCollection.cc
107 // Adds an IComponent to the Container. With a name binding.
110 public virtual void Add (IComponent component, string name)
112 // FIXME: Add this component to the ComponentCollection.cc
116 // Returns an ISite for a component.
118 protected virtual ISite CreateSite (IComponent component, string name)
120 return new DefaultSite (name, component, this);
123 public void Dispose ()
126 GC.SuppressFinalize (this);
129 bool disposed = false;
131 protected virtual void Dispose (bool release_all)
150 protected virtual object GetService (Type service)
152 // FIXME: Not clear what GetService does.
158 public virtual void Remove (IComponent component)
160 // FIXME: Add this component to the ComponentCollection.cc