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.

你可以ComponentIContainer实现接口的任何对象中承载, 并且可以从其容器中查询和获取服务。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所有组件也会被释放。 ContainerWhen 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

获取 IContainer,它包含 ComponentGets 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)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。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 占用的非托管资源,还可以另外再释放托管资源。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()

在通过垃圾回收将 Component 回收之前,释放非托管资源并执行其他清理操作。Releases 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()

检索控制此实例的生存期策略的当前生存期服务对象。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 的浅表副本。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 的名称的 String(如果有)。Returns 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.

适用于

另请参阅