Browse Source

2001-08-02 Miguel de Icaza <[email protected]>

	* Container.cs, Component.cs, IContainer.cs, IComponent.cs,
	ComponentCollection.cs, ISite.cs: New classes

2001-08-02  Miguel de Icaza  <[email protected]>

	* IServiceProvider.cs, EventHandler.cs: New files.

svn path=/trunk/mcs/; revision=387
Miguel de Icaza 24 years ago
parent
commit
b691f286c7

+ 5 - 0
mcs/class/System/System.ComponentModel/ChangeLog

@@ -0,0 +1,5 @@
+2001-08-02  Miguel de Icaza  <[email protected]>
+
+	* Container.cs, Component.cs, IContainer.cs, IComponent.cs,
+	ComponentCollection.cs, ISite.cs: New classes
+

+ 100 - 0
mcs/class/System/System.ComponentModel/Component.cs

@@ -0,0 +1,100 @@
+//
+// System.ComponentModel.Component.cs
+//
+// Author:
+//   Miguel de Icaza ([email protected])
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+
+namespace System.ComponentModel {
+
+	// <summary>
+	//   Component class.
+	// </summary>
+	//
+	// <remarks>
+	//   Longer description
+	// </remarks>
+	public class Component : MarshalByRefObject, IComponent, IDisposable {
+
+		IContainer       icontainer;
+		bool             design_mode;
+		EventHandlerList event_handlers;
+		ISite            isite;
+
+		// <summary>
+		//   Component Constructor
+		// </summary>
+		public Component ()
+		{
+		}
+
+		// <summary>
+		//   Get IContainer of this Component
+		// </summary>
+		public IContainer Container {
+			get {
+				return icontainer;
+			}
+		}
+
+		protected bool DesignMode {
+			get {
+				return design_mode;
+			}
+		}
+
+		protected EventHandlerList Events {
+			get {
+				return event_handlers;
+			}
+		}
+
+		public virtual ISite Site {
+			get {
+				return isite;
+			}
+
+			set {
+				isite = value;
+			}
+		}
+
+
+		// <summary>
+		//   Dispose resources used by this component
+		// </summary>
+		public virtual void Dispose ()
+		{
+		}
+
+		// <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>
+		protected virtual object GetService (Type service)
+		{
+		}
+
+		// <summary>
+		//   FIXME: Figure out this one.
+	        // </summary>
+		public event EventHandler Disposed;
+	}
+	
+}

+ 15 - 0
mcs/class/System/System.ComponentModel/ComponentCollection.cs

@@ -0,0 +1,15 @@
+//
+// System.ComponentModel.ComponentCollection.cs
+//
+// Author:
+//   Miguel de Icaza ([email protected])
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+
+namespace System.ComponentModel {
+
+	public class ComponentCollection { // FIXME: ReadOnlyCollectionBase
+	}
+}
+			

+ 143 - 0
mcs/class/System/System.ComponentModel/Container.cs

@@ -0,0 +1,143 @@
+//
+// System.ComponentModel.Container.cs
+//
+// Author:
+//   Miguel de Icaza ([email protected])
+//
+// (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;
+			
+			void DefaultSite (string name, IComponent component, IContainer container)
+			{
+				this.component = component;
+				this.container = container;
+				this.name = name;
+			}
+
+			IComponent Component {
+				get {
+					return component;
+				}
+			}
+
+			IContainer Container {
+				get {
+					return container;
+				}
+			}
+
+			bool DesignMode {
+				get {
+					// FIXME: should we provide a way to set
+					// this value?
+					return false;
+				}
+			}
+
+			string Name {
+				get {
+					return name;
+				}
+			}
+		}
+		
+		// <summary>
+		//   Container constructor
+		// </summary>
+		public Container ()
+		{
+		}
+
+		public virtual ComponentCollection Components {
+			get {
+				return cc;
+			}
+		}
+
+		// <summary>
+		//   Adds an IComponent to the Container
+		// </summary>
+		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>
+		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 DefaultSite (name, component, this);
+		}
+
+		public virtual void Dispose ()
+		{
+			Dispose (true);
+			GC.SupressFinalize (this);
+		}
+
+		bool disposed = false;
+		
+		public virtual void Dispose (bool release_all)
+		{
+			if (disposed)
+				return;
+
+			if (release_all){
+				cc.Dispose ();
+				cc = null;
+			}
+
+			disposed = true;
+		}
+
+		protected virtual object GetService (Type service)
+		{
+			// FIXME: Not clear what GetService does.
+			
+			return null;
+		}
+
+		public virtual void Remove (IComponent component)
+		{
+			// FIXME: Add this component to the ComponentCollection.cc
+		}
+	}
+	
+}

+ 20 - 0
mcs/class/System/System.ComponentModel/IComponent.cs

@@ -0,0 +1,20 @@
+//
+// System.ComponentModel.IComponent.cs
+//
+// Author:
+//   Miguel de Icaza ([email protected])
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+
+namespace System.ComponentModel {
+
+	public interface IComponent : IDisposable {
+
+		ISite Site {
+			get; set;
+		}
+
+		event EventHandler Disposed;
+	}
+}

+ 24 - 0
mcs/class/System/System.ComponentModel/IContainer.cs

@@ -0,0 +1,24 @@
+//
+// System.ComponentModel.IContainer.cs
+//
+// Author:
+//   Miguel de Icaza ([email protected])
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+
+namespace System.ComponentModel {
+
+	public interface IContainer {
+
+		ComponentCollection Components {
+			get;
+		}
+
+		void Add (IComponent component);
+
+		void Add (IComponent component, string name);
+
+		void Remove (IComponent component);
+	}
+}

+ 21 - 0
mcs/class/System/System.ComponentModel/ISite.cs

@@ -0,0 +1,21 @@
+//
+// System.ComponentModel.Component.cs
+//
+// Author:
+//   Miguel de Icaza ([email protected])
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+
+namespace System.ComponentModel {
+
+	public interface ISite : IServiceProvider {
+		IComponent Component { get; }
+
+		IContainer Container { get; }
+
+		bool DesignMode { get; }
+
+		string Name { get; set; }
+	}
+}

+ 7 - 0
mcs/class/System/System.ComponentModel/common.src

@@ -0,0 +1,7 @@
+Component.cs
+ComponentCollection.cs
+ComponentEditor.cs
+Container.cs
+IComponent.cs
+IContainer.cs
+ISite.cs

+ 0 - 0
mcs/class/System/System.ComponentModel/unix.src


+ 0 - 0
mcs/class/System/System.ComponentModel/windows.src


+ 1 - 1
mcs/class/System/makefile

@@ -1,4 +1,4 @@
-DIRS=System.CodeDom System.CodeDom.Compiler System.Net System.Net.Sockets System.Collections.Specialized 
+DIRS=System.CodeDom System.CodeDom.Compiler System.ComponentModel System.Net System.Net.Sockets System.Collections.Specialized 
 
 all:
 	@echo "You must use 'make windows' or 'make unix'."

+ 4 - 0
mcs/class/corlib/System/ChangeLog

@@ -1,3 +1,7 @@
+2001-08-02  Miguel de Icaza  <[email protected]>
+
+	* IServiceProvider.cs, EventHandler.cs: New files.
+
 2001-08-02  Marcel Narings  <[email protected]>
 	
 	* DateTime.cs: Cleaned up a bit. Added the Add* family members.

+ 16 - 0
mcs/class/corlib/System/EventHandler.cs

@@ -0,0 +1,16 @@
+//
+// System.EventHandler.cs
+//
+// Author:
+//   Miguel de Icaza ([email protected])
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+
+namespace System {
+
+	public delegate void EventHandler (object sender, EventArgs e);
+
+}
+
+

+ 17 - 0
mcs/class/corlib/System/IServiceProvider.cs

@@ -0,0 +1,17 @@
+//
+// System.IServiceProvider.cs
+//
+// Author:
+//   Miguel de Icaza ([email protected])
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+
+namespace System {
+
+	public interface IServiceProvider {
+
+		object GetService (Type serviceType);
+
+	}
+}

+ 4 - 3
mcs/class/corlib/System/RuntimeTypeHandle.cs

@@ -11,12 +11,13 @@ using System.Runtime.Serialization;
 
 namespace System {
 
+	// FIXME: Implement me!
 	public struct RuntimeTypeHandle : ISerializable {
-
+		IntrPtr value;
+		
 		public IntPtr Value {
 			get {
-				// FIXME: Implement me!
-				return (IntPtr) 0;
+				return (IntPtr) value;
 			}
 		}
 		

+ 3 - 0
mcs/class/corlib/System/common.src

@@ -13,6 +13,8 @@ Convert.cs
 DivideByZeroException.cs
 Double.cs
 DuplicateWaitObjectException.cs
+EventArgs.cs
+EventHandler.cs
 Exception.cs
 ExecutionEngineException.cs
 FormatException.cs
@@ -30,6 +32,7 @@ Int64.cs
 InvalidCastException.cs
 InvalidOperationException.cs
 InvalidProgramException.cs
+IServiceProvider.cs
 Math.cs
 MulticastNotSupportedException.cs
 NotFiniteNumberException.cs