Component 类

定义

提供 IComponent 接口的基实现并启用应用程序之间的对象共享。Provides the base implementation for the IComponent interface and enables object sharing between applications.

public ref class Component : MarshalByRefObject, IDisposable, System::ComponentModel::IComponent
public ref class Component : MarshalByRefObject, System::ComponentModel::IComponent
public class Component : MarshalByRefObject, IDisposable, System.ComponentModel.IComponent
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
public class Component : MarshalByRefObject, IDisposable, System.ComponentModel.IComponent
public class Component : MarshalByRefObject, System.ComponentModel.IComponent
type Component = class
    inherit MarshalByRefObject
    interface IComponent
    interface IDisposable
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Component = class
    inherit MarshalByRefObject
    interface IComponent
    interface IDisposable
Public Class Component
Inherits MarshalByRefObject
Implements IComponent, IDisposable
Public Class Component
Inherits MarshalByRefObject
Implements IComponent
继承
派生
属性
实现

注解

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 提供接口的实现 IComponentComponent provides an implementation of the IComponent interface. MarshalByValueComponent提供 IComponent 通过值封送的的实现。The 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 为它包含的每个创建一个 ComponentThe 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.

Component应通过调用方法显式释放资源 Dispose ,而无需通过隐式调用方法来等待自动内存管理 FinalizeA 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 类的新实例。Initializes a new instance of the Component class.

属性

CanRaiseEvents

获取一个指示组件是否可以引发事件的值。Gets a value indicating whether the component can raise an event.

Container

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

DesignMode

获取一个值,用以指示 Component 当前是否处于设计模式。Gets a value that indicates whether the Component is currently in design mode.

Events

获取附加到此 Component 的事件处理程序的列表。Gets the list of event handlers that are attached to this Component.

Site

获取或设置 ComponentISiteGets or sets the ISite of the Component.

方法

CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(继承自 MarshalByRefObject)
Dispose()

释放由 Component 使用的所有资源。Releases all resources used by the Component.

Dispose(Boolean)

释放由 Component 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the Component and optionally releases the managed resources.

Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
Finalize()

在通过垃圾回收将 Component 回收之前,释放非托管资源并执行其他清理操作。Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(继承自 MarshalByRefObject)
GetService(Type)

返回一个对象,该对象表示由 Component 或它的 Container 提供的服务。Returns an object that represents a service provided by the Component or by its Container.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(继承自 MarshalByRefObject)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(继承自 MarshalByRefObject)
ToString()

返回包含 Component 的名称的 String(如果有)。Returns a String containing the name of the Component, if any. 不应重写此方法。This method should not be overridden.

事件

Disposed

在通过调用 Dispose() 方法释放组件时发生。Occurs when the component is disposed by a call to the Dispose() method.

适用于

另请参阅