Edit

Share via


DesignerSerializationManager.RecycleInstances Property

Definition

Gets or sets a value that indicates whether CreateInstance(Type, ICollection, String, Boolean) will always create a new instance of a type.

public:
 property bool RecycleInstances { bool get(); void set(bool value); };
public bool RecycleInstances { get; set; }
member this.RecycleInstances : bool with get, set
Public Property RecycleInstances As Boolean

Property Value

true if CreateInstance(Type, ICollection, String, Boolean) will return the existing instance; false if CreateInstance(Type, ICollection, String, Boolean) will create a new instance of a type. The default is false.

Exceptions

The serialization manager has an active serialization session.

Remarks

If the RecycleInstances property is false, the CreateInstance method will always create a new instance of a type. If RecycleInstances is true, CreateInstance will first search the name table and container for an object of the same name. If such an object exists and is of the same type, CreateInstance will return the existing instance. This second variation is useful for implementing a serializer that applies serialization state to an existing set of objects, rather than always creating a new tree. The Undo command often uses this type of serializer.

In the case where the RecycleInstances property is true, the ValidateRecycledTypes property will further modify the behavior of CreateInstance depending on the types of the two objects.

Applies to

See also