public class Component : MarshalByRefObject, IComponent, IDisposable
|
You can host a Component in any object that implements the IContainer interface, and can query and get services from its container. The container creates an ISite for each Component it contains. The container uses the site to manage the Component and is used by the Component to communicate with its container.
It is recommended that a Component release resources explicitly by calls to its Component.Dispose method, without waiting for automatic memory management through an implicit call to Object.Finalize. When a Container is disposed, all components within the Container are also disposed.
ctor #1 | Default constructor. This constructor is called by derived class constructors to initialize state in this type. |
Container | Read-only Gets the IContainer that contains the Component. |
Site | Read-write Gets or sets the ISite of the Component. |
CreateObjRef (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.CreateObjRef Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. |
Dispose | Overloaded:Dispose() Releases all resources used by the Component. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetLifetimeService (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.GetLifetimeService Retrieves the current lifetime service object that controls the lifetime policy for this instance. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
InitializeLifetimeService (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.InitializeLifetimeService Obtains a lifetime service object to control the lifetime policy for this instance. |
ToString | Overridden: Returns a String containing the name of the Component, if any. This method should not be overridden. For internal use only. |
Disposed | Adds an event handler to listen to the Component.Disposed event on the component. |
DesignMode | Read-only Gets a value that indicates whether the Component is currently in design mode. |
Events | Read-only Gets the list of event handlers that are attached to this Component. |
Dispose | Overloaded:Dispose(bool disposing) Releases the unmanaged resources used by the Component and optionally releases the managed resources. |
Finalize | Overridden: |
GetService | Returns an object that represents a service provided by the Component or by its Container. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public Component(); |
public IContainer Container {get;}
|
protected bool DesignMode {get;}
|
protected EventHandlerList Events {get;}
|
public virtual ISite Site {get; set;}
|
The property value is null if the Component is removed from its IContainer. Assigning null to this property does not necessarily remove the Component from the IContainer.
A Component might or might not have a name. If a Component is given a name, the name must be unique among other Component objects within its IContainer. The ISite stores the name of the Component; therefore, you can only name a Component if it has an ISite associated with it.
requestedType
Exception Type | Condition |
---|---|
RemotingException | This instance is not a valid remoting object. |
public void Dispose(); |
protected virtual void Dispose( |
disposing
When the disposing parameter is true, this method releases all resources held by any managed objects that this Component references. This method invokes the Dispose() method of each referenced object.
For more information about Dispose and Object.Finalize, see the conceptual topic at MSDN: cleaningupunmanagedresources and the conceptual topic at MSDN: overridingfinalizemethod.
~Component(); |
public virtual int GetHashCode(); |
public object GetLifetimeService(); |
service
This value is null if the Component does not provide the specified service.
public Type GetType(); |
public virtual object InitializeLifetimeService(); |
public class MyClass : MarshalByRefObject { public override Object InitializeLifetimeService() { ILease lease = (ILease)base.InitializeLifetimeService(); if (lease.CurrentState == LeaseState.Initial) { lease.InitialLeaseTime = TimeSpan.FromMinutes(1); lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); lease.RenewOnCallTime = TimeSpan.FromSeconds(2); } return lease; } }
protected object MemberwiseClone(); |
public override string ToString(); |
null if the Component is unnamed.
The ISite stores the Component 's name. A Component can only have a ISite if it has been added to an IContainer and the IContainer assigns an ISite to it.
public event EventHandler Disposed;
|