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

Container.cs « System.ComponentModel « System « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f1b6b58abb6685cb007e17b44ca697c89891b084 (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//
// System.ComponentModel.Container.cs
//
// Author:
//   Miguel de Icaza (miguel@ximian.com)
//
// (C) Ximian, Inc.  http://www.ximian.com
//

namespace System.ComponentModel {

	// <summary>
	//   Container class: encapsulates components.  
	// </summary>
	//
	// <remarks>
	//   
	// </remarks>
	public class Container : IContainer, IDisposable {
		ComponentCollection cc;

		// <summary>
		//   Auxiliary class to support the default behaviour of CreateSite
		// </summary>
		//
		// <remarks>
		//   This is an internal class that is used to provide a
		//   default implementation of an ISite class.  Container
		//   is just a default implementation of IContainer, and
		//   provides this as a way of getting started
		// </remarks>
		
		class DefaultSite : ISite {
			IComponent component;
			IContainer container;
			string     name;
			
			public DefaultSite (string name, IComponent component, IContainer container)
			{
				this.component = component;
				this.container = container;
				this.name = name;
			}

			public IComponent Component {
				get {
					return component;
				}
			}

			public IContainer Container {
				get {
					return container;
				}
			}

			[MonoTODO]
			public bool DesignMode {
				get {
					// FIXME: should we provide a way to set
					// this value?
					return false;
				}
			}

			public string Name {
				get {
					return name;
				}

				set {
					name = value;
				}
			}

			[MonoTODO]
			public virtual object GetService (Type t)
			{
				// FIXME: do not know what this is supposed to do.
				return null;
			}
		}
		
		// <summary>
		//   Container constructor
		// </summary>
		public Container ()
		{
		}

		public virtual ComponentCollection Components {
			get {
				return cc;
			}
		}

		// <summary>
		//   Adds an IComponent to the Container
		// </summary>
		[MonoTODO]
		public virtual void Add (IComponent component)
		{
			// FIXME: Add this component to the ComponentCollection.cc
		}

		// <summary>
		//   Adds an IComponent to the Container.  With a name binding.
		// </summary>
		[MonoTODO]
		public virtual void Add (IComponent component, string name)
		{
			// FIXME: Add this component to the ComponentCollection.cc
		}

		// <summary>
		//   Returns an ISite for a component.
		// <summary>
		protected virtual ISite CreateSite (IComponent component, string name)
		{
			return new DefaultSite (name, component, this);
		}

		public void Dispose ()
		{
			Dispose (true);
			GC.SuppressFinalize (this);
		}

		bool disposed = false;
		
		protected virtual void Dispose (bool release_all)
		{
			if (disposed)
				return;

			if (release_all){
				cc.Dispose ();
				cc = null;
			}

			disposed = true;
		}

		[MonoTODO]
		protected virtual object GetService (Type service)
		{
			// FIXME: Not clear what GetService does.
			
			return null;
		}

		[MonoTODO]
		public virtual void Remove (IComponent component)
		{
			// FIXME: Add this component to the ComponentCollection.cc
		}
	}
	
}