DesignerSerializationManager.CreateInstance 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立一個類型的實例。
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);
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 轉換以尋找匹配的建構子。