2 // System.ComponentModel.Component.cs
5 // Miguel de Icaza (miguel@ximian.com)
7 // (C) Ximian, Inc. http://www.ximian.com
12 namespace System.ComponentModel {
21 public class Component : MarshalByRefObject, IComponent, IDisposable {
23 EventHandlerList event_handlers;
27 // Component Constructor
31 event_handlers = null;
35 // Get IContainer of this Component
37 public IContainer Container {
39 return mySite.Container;
43 protected bool DesignMode {
45 return mySite.DesignMode;
49 protected EventHandlerList Events {
51 // Note: space vs. time tradeoff
52 // We create the object here if it's never be accessed before. This potentially
53 // saves space. However, we must check each time the propery is accessed to
54 // determine whether we need to create the object, which increases overhead.
55 // We could put the creation in the contructor, but that would waste space
56 // if it were never used. However, accessing this property would be faster.
57 if (null == event_handlers)
\r
59 event_handlers = new EventHandlerList();
61 return event_handlers;
65 public virtual ISite Site {
78 // FIXME: Not sure this is correct.
83 // Dispose resources used by this component
86 public void Dispose ()
88 // FIXME: Not sure this is correct.
91 Disposed(this, EventArgs.Empty);
95 // Controls disposal of resources used by this.
98 // <param name="release_all"> Controls which resources are released</param>
101 // if release_all is set to true, both managed and unmanaged
102 // resources should be released. If release_all is set to false,
103 // only unmanaged resources should be disposed
105 protected virtual void Dispose (bool release_all)
110 // Implements the IServiceProvider interface
113 protected virtual object GetService (Type service)
115 // FIXME: Not sure what this should do.
119 public override string ToString ()
122 return GetType ().ToString ();
123 return String.Format ("{0} [{1}]", mySite.Name, GetType ().ToString ());
126 // FIXME: Figure out this one.
128 [MonoTODO ("Figure this out")]
129 public event EventHandler Disposed;