TypeConverter.CreateInstance TypeConverter.CreateInstance TypeConverter.CreateInstance TypeConverter.CreateInstance Method

定义

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

重载

CreateInstance(ITypeDescriptorContext, IDictionary) CreateInstance(ITypeDescriptorContext, IDictionary) CreateInstance(ITypeDescriptorContext, IDictionary) 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) CreateInstance(IDictionary) CreateInstance(IDictionary) CreateInstance(IDictionary)

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

CreateInstance(ITypeDescriptorContext, IDictionary) CreateInstance(ITypeDescriptorContext, IDictionary) CreateInstance(ITypeDescriptorContext, IDictionary) 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 ITypeDescriptorContext ITypeDescriptorContext

一个 ITypeDescriptorContext,用于提供格式上下文。An ITypeDescriptorContext that provides a format context.

propertyValues
IDictionary IDictionary IDictionary 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) CreateInstance(IDictionary) CreateInstance(IDictionary) 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 IDictionary 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参数均具有一系列的名称/值对,一个用于每个属性返回从GetPropertiesThe dictionary provided by the propertyValues parameter has a series of name/value pairs, one for each property returned from GetProperties.

另请参阅

适用于