//
// System.ComponentModel.Component.cs
//
// Author:
// Miguel de Icaza (miguel@ximian.com)
//
// (C) Ximian, Inc. http://www.ximian.com
//
using System;
namespace System.ComponentModel {
//
// Component class.
//
//
//
// Longer description
//
public class Component : MarshalByRefObject, IComponent, IDisposable {
EventHandlerList event_handlers;
ISite mySite;
//
// Component Constructor
//
public Component ()
{
}
//
// Get IContainer of this Component
//
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;
}
}
~Component()
{
// FIXME: Not sure this is correct.
Dispose(true);
Disposed(this, EventArgs.Empty);
}
//
// Dispose resources used by this component
//
public virtual void Dispose ()
{
// FIXME: Not sure this is correct.
Dispose(false);
Disposed(this, EventArgs.Empty);
}
//
// Controls disposal of resources used by this.
//
//
// Controls which resources are released
//
//
// 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
//
protected virtual void Dispose (bool release_all)
{
}
//
// Implements the IServiceProvider interface
//
protected virtual object GetService (Type service)
{
// FIXME: Not sure what this should do.
return null;
}
//
// FIXME: Figure out this one.
//
public event EventHandler Disposed;
}
}