Component Component Component Component Class

定義

提供 IComponent 介面的基底實作,並啟用應用程式之間的物件共用。Provides the base implementation for the IComponent interface and enables object sharing between applications.

public ref class Component : MarshalByRefObject, IDisposable, System::ComponentModel::IComponent
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
public class Component : MarshalByRefObject, IDisposable, System.ComponentModel.IComponent
type Component = class
    inherit MarshalByRefObject
    interface IComponent
    interface IDisposable
Public Class Component
Inherits MarshalByRefObject
Implements IComponent, IDisposable
繼承
衍生
屬性
實作

備註

Component是通用語言執行時間中, 以傳址方式封送處理之所有元件的基類。Component is the base class for all components in the common language runtime that marshal by reference. Component可遠端處理且衍生自MarshalByRefObject類別。Component is remotable and derives from the MarshalByRefObject class. Component提供IComponent介面的執行。Component provides an implementation of the IComponent interface. IComponent會提供以傳值方式封送處理的執行。 MarshalByValueComponentThe MarshalByValueComponent provides an implementation of IComponent that marshals by value.

您可以Component在任何執行IContainer介面的物件中裝載, 而且可以從其容器查詢和取得服務。You can host a Component in any object that implements the IContainer interface, and you can query and get services from its container. 容器會ISite為它所包含Component的每個建立。The container creates an ISite for each Component it contains. 容器會使用網站來管理Component , 並使用Component來與其容器通訊。The container uses the site to manage the Component and is used by the Component to communicate with its container.

應該藉由呼叫其Dispose方法來明確釋放資源, 而不需透過對Finalize方法的隱含呼叫來等候自動記憶體管理。 ComponentA Component should release resources explicitly by calls to its Dispose method, without waiting for automatic memory management through an implicit call to the Finalize method. 當處置Container時, 中的Container所有元件也會一併處置。When a Container is disposed, all components within the Container are also disposed.

建構函式

Component() Component() Component() Component()

初始化 Component 類別的新執行個體。Initializes a new instance of the Component class.

屬性

CanRaiseEvents CanRaiseEvents CanRaiseEvents CanRaiseEvents

取得值,指出元件是否能引發事件。Gets a value indicating whether the component can raise an event.

Container Container Container Container

取得包含 IContainerComponentGets the IContainer that contains the Component.

DesignMode DesignMode DesignMode DesignMode

取得值,指出 Component 目前是否處於設計模式。Gets a value that indicates whether the Component is currently in design mode.

Events Events Events Events

取得附加在這個 Component 上的事件處理常式清單。Gets the list of event handlers that are attached to this Component.

Site Site Site Site

取得或設定 ComponentISiteGets or sets the ISite of the Component.

方法

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

釋放 Component 所使用的所有資源。Releases all resources used by the Component.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

釋放 Component 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the Component and optionally releases the managed resources.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize() Finalize() Finalize() Finalize()

釋出 Unmanaged 資源並執行其他清除作業後,記憶體回收才能重新回收 ComponentReleases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

傳回表示 Component 或其 Container 所提供之服務的物件。Returns an object that represents a service provided by the Component or by its Container.

GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

取得存留期服務物件,以控制這個執行個體的存留期原則。Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
ToString() ToString() ToString() ToString()

傳回任何包含 Component 名稱的 StringReturns a String containing the name of the Component, if any. 不應覆寫此方法。This method should not be overridden.

事件

Disposed Disposed Disposed Disposed

當此元件由 Dispose() 方法的呼叫處置時發生。Occurs when the component is disposed by a call to the Dispose() method.

適用於

另請參閱