Container Container Container Container Class

定义

封装零个或更多个组件。Encapsulates zero or more components.

public ref class Container : IDisposable, System::ComponentModel::IContainer
public class Container : IDisposable, System.ComponentModel.IContainer
type Container = class
    interface IContainer
    interface IDisposable
Public Class Container
Implements IContainer, IDisposable
继承
ContainerContainerContainerContainer
派生
实现

注解

类是IContainer接口的默认实现。 ContainerThe Container class is the default implementation for the IContainer interface.

容器是封装和跟踪零个或多个组件的对象。Containers are objects that encapsulate and track zero or more components. 在此上下文中, 包含关系是指逻辑包含关系, 而不是可视包容。In this context, containment refers to logical containment, not visual containment. 你可以在各种方案中使用组件和容器, 包括视觉对象和非视觉对象的方案。You can use components and containers in a variety of scenarios, including scenarios that are both visual and not visual.

容器中的组件在先进先出列表中跟踪, 此列表还定义了组件在容器中的顺序。The components in a container are tracked in a first-in, first-out list, which also defines the order of the components within the container. 添加的组件将追加到列表的末尾。Added components are appended to the end of the list.

构造函数

Container() Container() Container() Container()

初始化 Container 类的新实例。Initializes a new instance of the Container class.

属性

Components Components Components Components

获取 Container 中的所有组件。Gets all the components in the Container.

方法

Add(IComponent) Add(IComponent) Add(IComponent) Add(IComponent)

将指定的 Component 添加到 ContainerAdds the specified Component to the Container. 该组件未命名。The component is unnamed.

Add(IComponent, String) Add(IComponent, String) Add(IComponent, String) Add(IComponent, String)

将指定的 Component 添加到 Container 并为其分配名称。Adds the specified Component to the Container and assigns it a name.

CreateSite(IComponent, String) CreateSite(IComponent, String) CreateSite(IComponent, String) CreateSite(IComponent, String)

为给定的 ISite 创建一个站点 IComponent,并将给定名称分配给该站点。Creates a site ISite for the given IComponent and assigns the given name to the site.

Dispose() Dispose() Dispose() Dispose()

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

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

释放由 Container 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the Container, 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()

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

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

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

(Inherited from Object)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

获取指定类型的服务对象(如果可用)。Gets the service object of the specified type, if it is available.

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

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

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

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

(Inherited from Object)
Remove(IComponent) Remove(IComponent) Remove(IComponent) Remove(IComponent)

Container 中移除组件。Removes a component from the Container.

RemoveWithoutUnsiting(IComponent) RemoveWithoutUnsiting(IComponent) RemoveWithoutUnsiting(IComponent) RemoveWithoutUnsiting(IComponent)

Container 中移除组件,不将 Site 设置为 nullRemoves a component from the Container without setting Site to null.

ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)
ValidateName(IComponent, String) ValidateName(IComponent, String) ValidateName(IComponent, String) ValidateName(IComponent, String)

确定组件名称对此容器是否唯一。Determines whether the component name is unique for this container.

适用于

另请参阅