Add System.Web to the make process
[mono.git] / mcs / class / System / System.ComponentModel / Component.cs
1 //
2 // System.ComponentModel.Component.cs
3 //
4 // Author:
5 //   Miguel de Icaza (miguel@ximian.com)
6 //
7 // (C) Ximian, Inc.  http://www.ximian.com
8 //
9
10 using System;
11
12 namespace System.ComponentModel {
13
14         // <summary>
15         //   Component class.
16         // </summary>
17         //
18         // <remarks>
19         //   Longer description
20         // </remarks>
21         public class Component : MarshalByRefObject, IComponent, IDisposable {
22
23                 EventHandlerList event_handlers;
24                 ISite            mySite;
25
26                 // <summary>
27                 //   Component Constructor
28                 // </summary>
29                 public Component ()
30                 {
31                         event_handlers = null;
32                 }
33
34                 // <summary>
35                 //   Get IContainer of this Component
36                 // </summary>
37                 public IContainer Container {
38                         get {
39                                 return mySite.Container;
40                         }
41                 }
42
43                 protected bool DesignMode {
44                         get {
45                                 return mySite.DesignMode;
46                         }
47                 }
48
49                 protected EventHandlerList Events {
50                         get {
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
58                                 {
59                                         event_handlers = new EventHandlerList();
60                                 }
61                                 return event_handlers;
62                         }
63                 }
64
65                 public virtual ISite Site {
66                         get {
67                                 return mySite;
68                         }
69
70                         set {
71                                 mySite = value;
72                         }
73                 }
74
75                 ~Component()
76                 {
77                         // FIXME: Not sure this is correct.
78                         Dispose(true);
79                         Disposed(this, EventArgs.Empty);
80                 }
81
82                 // <summary>
83                 //   Dispose resources used by this component
84                 // </summary>
85                 public virtual void Dispose ()
86                 {
87                         // FIXME: Not sure this is correct.
88                         Dispose(false);
89                         Disposed(this, EventArgs.Empty);
90                 }
91
92                 // <summary>
93                 //   Controls disposal of resources used by this.
94                 // </summary>
95                 //
96                 // <param name="release_all"> Controls which resources are released</param>
97                 //
98                 // <remarks>
99                 //   if release_all is set to true, both managed and unmanaged
100                 //   resources should be released.  If release_all is set to false,
101                 //   only unmanaged resources should be disposed
102                 // </remarks>
103                 protected virtual void Dispose (bool release_all)
104                 {
105                 }
106
107                 // <summary>
108                 //   Implements the IServiceProvider interface
109                 // </summary>
110                 protected virtual object GetService (Type service)
111                 {
112                         // FIXME: Not sure what this should do.
113                         return null;
114                 }
115
116                 // <summary>
117                 //   FIXME: Figure out this one.
118                 // </summary>
119                 public event EventHandler Disposed;
120         }
121         
122 }