Share via


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

true 表示物件實作 IComponent 時將物件加入容器,否則為 false

傳回

type 指定之型別的新執行個體。

例外狀況

type 沒有使用 arguments 中所包含之參數的建構函式。

備註

當串行化程序嘗試建立類型的實例時,會呼叫這個方法。 默認實作會建立型別的新實例,或者可能會根據 和 RecycleInstances 屬性的值PreserveNames傳回現有的實例。 方法 CreateInstance 會使用反映來建立實例,並在參數上執行一些泛型 IConvertible 轉換,以尋找相符的建構函式。

適用於

另請參閱