DesignerSerializationManager.CreateInstance 方法

定义

创建类型的实例。

protected:
 virtual System::Object ^ CreateInstance(Type ^ type, System::Collections::ICollection ^ arguments, System::String ^ name, bool addToContainer);
protected virtual object CreateInstance(Type type, System.Collections.ICollection arguments, string name, bool addToContainer);
protected virtual object CreateInstance(Type type, System.Collections.ICollection? arguments, string? name, bool addToContainer);
abstract member CreateInstance : Type * System.Collections.ICollection * string * bool -> obj
override this.CreateInstance : Type * System.Collections.ICollection * string * bool -> obj
Protected Overridable Function CreateInstance (type As Type, arguments As ICollection, name As String, addToContainer As Boolean) As Object

参数

type
Type

要创建其实例的类型。

arguments
ICollection

类型的构造函数的参数。 这可以是 null 或空集合来调用无参数构造函数。

name
String

要为对象提供的名称。 如果 null为对象,则不会为对象指定名称,除非对象被添加到容器中,并且容器为对象指定名称。

addToContainer
Boolean

如果对象实现 ,则向容器添加对象;否则为 < a0 />。

返回

type该类型指定的新实例。

例外

type 没有采用包含在中的参数的 arguments构造函数。

注解

当序列化程序尝试创建类型的实例时,将调用此方法。 默认实现将创建类型的新实例,或者可能会返回现有实例,具体取决于属性的值PreserveNamesRecycleInstances。 该方法 CreateInstance 使用反射来创建实例,并将对参数执行一些泛型 IConvertible 转换来查找匹配的构造函数。

适用于

另请参阅