TypeConverter.CreateInstance 方法

定义

在给定 Object 的一组属性值的情况下重新创建该对象。Re-creates an Object given a set of property values for the object.

重载

CreateInstance(ITypeDescriptorContext, IDictionary)

给定该对象的一组属性值,使用指定上下文创建与此 TypeConverter 相关联的类型的实例。Creates an instance of the type that this TypeConverter is associated with, using the specified context, given a set of property values for the object.

CreateInstance(IDictionary)

在给定 Object 的一组属性值的情况下重新创建该对象。Re-creates an Object given a set of property values for the object.

CreateInstance(ITypeDescriptorContext, IDictionary)

给定该对象的一组属性值,使用指定上下文创建与此 TypeConverter 相关联的类型的实例。Creates an instance of the type that this TypeConverter is associated with, using the specified context, given a set of property values for the object.

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);
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,用于提供格式上下文。An ITypeDescriptorContext that provides a format context.

propertyValues
IDictionary

新属性值的 IDictionaryAn IDictionary of new property values.

返回

如果表示给定 IDictionary,则为 Object,或如果无法创建对象,则为 nullAn Object representing the given IDictionary, or null if the object cannot be created. 此方法始终返回 nullThis method always returns null.

注解

此方法可用于不可变的对象, 但要为其提供可变属性的对象。Use this method for objects that are immutable, but for which you want to provide changeable properties.

继承者说明

如果要转换的类型必须重新创建要更改其值的对象, 请重写此方法。Override this method if the type you want to convert must re-create the object to change its value.

使用 context 参数提取有关调用此转换器的环境的附加信息。Use the context parameter to extract additional information about the environment from which this converter is invoked. 此参数可以是null, 因此请始终选中此参数。This parameter can be null, so always check it. 同样,上下文对象的属性可以返回 nullAlso, properties on the context object can return null.

propertyValues参数提供的字典包含一系列名称/值对, 每个名称/值对都是从GetProperties(Object)返回的每个属性一个。The dictionary provided by the propertyValues parameter has a series of name/value pairs, one for each property returned from GetProperties(Object).

另请参阅

CreateInstance(IDictionary)

在给定 Object 的一组属性值的情况下重新创建该对象。Re-creates an Object given a set of property values for the object.

public:
 System::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,表示新属性值的字典。An IDictionary that represents a dictionary of new property values.

返回

如果表示给定 IDictionary,则为 Object,或如果无法创建对象,则为 nullAn Object representing the given IDictionary, or null if the object cannot be created. 此方法始终返回 nullThis method always returns null.

注解

此方法可用于不可变的对象, 但要为其提供可变属性的对象。Use this method for objects that are immutable, but for which you want to provide changeable properties.

propertyValues参数提供的字典包含一系列名称/值对, 每个名称/值对都是从GetProperties返回的每个属性一个。The dictionary provided by the propertyValues parameter has a series of name/value pairs, one for each property returned from GetProperties.

另请参阅

适用于