DesignerSerializationManager.CreateInstance Metodo

Definizione

Crea un'istanza di un tipo.

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

Parametri

type
Type

Tipo di cui creare un'istanza.

arguments
ICollection

Parametri del costruttore del tipo. Può essere null o una raccolta vuota per richiamare il costruttore senza parametri.

name
String

Nome da assegnare all'oggetto. Se null, non verrà assegnato un nome all'oggetto a meno che l'oggetto non venga aggiunto a un contenitore e sia quest'ultimo ad assegnargli un nome.

addToContainer
Boolean

true per aggiungere l'oggetto al contenitore se implementa IComponent; in caso contrario, false.

Restituisce

Nuova istanza del tipo specificato da type.

Eccezioni

type non dispone di un costruttore che accetta i parametri contenuti in arguments.

Commenti

Questo metodo viene chiamato dai serializzatori quando tentano di creare un'istanza di un tipo. L'implementazione predefinita crea una nuova istanza del tipo oppure può restituire un'istanza esistente a seconda dei valori delle PreserveNames proprietà e RecycleInstances . Il CreateInstance metodo usa la reflection per creare istanze e eseguirà alcune trasformazioni generiche IConvertible sui parametri per trovare un costruttore corrispondente.

Si applica a

Vedi anche