TypeConverter.CreateInstance 方法

定义

在给定 Object 的一组属性值的情况下重新创建该对象。

重载

CreateInstance(ITypeDescriptorContext, IDictionary)

给定该对象的一组属性值,使用指定上下文创建与此 TypeConverter 相关联的类型的实例。

CreateInstance(IDictionary)

在给定 Object 的一组属性值的情况下重新创建该对象。

CreateInstance(ITypeDescriptorContext, IDictionary)

给定该对象的一组属性值,使用指定上下文创建与此 TypeConverter 相关联的类型的实例。

public:
 virtual System::Object ^ CreateInstance(System::ComponentModel::ITypeDescriptorContext ^ context, System::Collections::IDictionary ^ propertyValues);
public virtual object CreateInstance (System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary propertyValues);
public virtual object? CreateInstance (System.ComponentModel.ITypeDescriptorContext? context, System.Collections.IDictionary propertyValues);
abstract member CreateInstance : System.ComponentModel.ITypeDescriptorContext * System.Collections.IDictionary -> obj
override this.CreateInstance : System.ComponentModel.ITypeDescriptorContext * System.Collections.IDictionary -> obj
Public Overridable Function CreateInstance (context As ITypeDescriptorContext, propertyValues As IDictionary) As Object

参数

context
ITypeDescriptorContext

一个 ITypeDescriptorContext,用于提供格式上下文。

propertyValues
IDictionary

新属性值的 IDictionary

返回

Object

如果表示给定 IDictionary,则为 Object,或如果无法创建对象,则为 null。 此方法始终返回 null

注解

对不可变但要为其提供可更改属性的对象使用此方法。

继承者说明

如果要转换的类型必须重新创建对象以更改其值,请重写此方法。

使用 context 参数提取有关调用此转换器的环境的附加信息。 此参数可以是 null,因此请始终检查它。 同样,上下文对象的属性可以返回 null

参数提供的 propertyValues 字典具有一系列名称/值对,每个属性 GetProperties(Object)返回一个名称/值对。

另请参阅

适用于

CreateInstance(IDictionary)

在给定 Object 的一组属性值的情况下重新创建该对象。

public:
 System::Object ^ CreateInstance(System::Collections::IDictionary ^ propertyValues);
public object CreateInstance (System.Collections.IDictionary propertyValues);
public object? CreateInstance (System.Collections.IDictionary propertyValues);
member this.CreateInstance : System.Collections.IDictionary -> obj
Public Function CreateInstance (propertyValues As IDictionary) As Object

参数

propertyValues
IDictionary

一个 IDictionary,表示新属性值的字典。

返回

Object

如果表示给定 IDictionary,则为 Object,或如果无法创建对象,则为 null。 此方法始终返回 null

注解

对不可变但要为其提供可更改属性的对象使用此方法。

参数提供的 propertyValues 字典具有一系列名称/值对,每个属性 GetProperties返回一个名称/值对。

另请参阅

适用于