Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Component.cs « System.ComponentModel « System « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 37649d05e8f0ab3f5b710a24c3775e5f3ddabf33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//
// System.ComponentModel.Component.cs
//
// Author:
//   Miguel de Icaza (miguel@ximian.com)
//
// (C) Ximian, Inc.  http://www.ximian.com
//

using System;

namespace System.ComponentModel {

	// <summary>
	//   Component class.
	// </summary>
	//
	// <remarks>
	//   Longer description
	// </remarks>
	public class Component : MarshalByRefObject, IComponent, IDisposable {

		EventHandlerList event_handlers;
		ISite            mySite;

		// <summary>
		//   Component Constructor
		// </summary>
		public Component ()
		{
			event_handlers = null;
		}

		// <summary>
		//   Get IContainer of this Component
		// </summary>
		public IContainer Container {
			get {
				return mySite.Container;
			}
		}

		protected bool DesignMode {
			get {
				return mySite.DesignMode;
			}
		}

		protected EventHandlerList Events {
			get {
				// Note: space vs. time tradeoff
				// We create the object here if it's never be accessed before.  This potentially 
				// saves space. However, we must check each time the propery is accessed to
				// determine whether we need to create the object, which increases overhead.
				// We could put the creation in the contructor, but that would waste space
				// if it were never used.  However, accessing this property would be faster.
				if (null == event_handlers)
				{
					event_handlers = new EventHandlerList();
				}
				return event_handlers;
			}
		}

		public virtual ISite Site {
			get {
				return mySite;
			}

			set {
				mySite = value;
			}
		}

		[MonoTODO]
		~Component()
		{
			// FIXME: Not sure this is correct.
			Dispose(true);
			Disposed(this, EventArgs.Empty);
		}

		// <summary>
		//   Dispose resources used by this component
		// </summary>
		[MonoTODO]
		public virtual void Dispose ()
		{
			// FIXME: Not sure this is correct.
			Dispose(false);
			Disposed(this, EventArgs.Empty);
		}

		// <summary>
		//   Controls disposal of resources used by this.
		// </summary>
		//
		// <param name="release_all"> Controls which resources are released</param>
		//
		// <remarks>
		//   if release_all is set to true, both managed and unmanaged
		//   resources should be released.  If release_all is set to false,
		//   only unmanaged resources should be disposed
		// </remarks>
		protected virtual void Dispose (bool release_all)
		{
		}

		// <summary>
		//   Implements the IServiceProvider interface
		// </summary>
		[MonoTODO]
		protected virtual object GetService (Type service)
		{
			// FIXME: Not sure what this should do.
			return null;
		}

		// <summary>
		//   FIXME: Figure out this one.
	        // </summary>
		[MonoTODO ("Figure this out")]
		public event EventHandler Disposed;
	}
	
}