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

參數

propertyValues
IDictionary IDictionary IDictionary IDictionary

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

傳回

代表指定 IDictionaryObject;如果無法建立物件,則為 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.

傳回

代表指定 IDictionaryObject;如果無法建立物件,則為 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.

另請參閱

適用於