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
34 // Get IContainer of this Component
36 public IContainer Container {
38 return mySite.Container;
42 protected bool DesignMode {
44 return mySite.DesignMode;
48 protected EventHandlerList Events {
50 // Note: space vs. time tradeoff
51 // We create the object here if it's never be accessed before. This potentially
52 // saves space. However, we must check each time the propery is accessed to
53 // determine whether we need to create the object, which increases overhead.
54 // We could put the creation in the contructor, but that would waste space
55 // if it were never used. However, accessing this property would be faster.
56 if (null == event_handlers)
\r
58 event_handlers = new EventHandlerList();
60 return event_handlers;
64 public virtual ISite Site {
76 // FIXME: Not sure this is correct.
78 Disposed(this, EventArgs.Empty);
82 // Dispose resources used by this component
84 public virtual void Dispose ()
86 // FIXME: Not sure this is correct.
88 Disposed(this, EventArgs.Empty);
92 // Controls disposal of resources used by this.
95 // <param name="release_all"> Controls which resources are released</param>
98 // if release_all is set to true, both managed and unmanaged
99 // resources should be released. If release_all is set to false,
100 // only unmanaged resources should be disposed
102 protected virtual void Dispose (bool release_all)
107 // Implements the IServiceProvider interface
109 protected virtual object GetService (Type service)
111 // FIXME: Not sure what this should do.
116 // FIXME: Figure out this one.
118 public event EventHandler Disposed;