In This Article

CloneOptions Class

Defines options which define how an object is cloned.

public class CloneOptions
Inheritance:
object object

Constructors

CloneOptions()

Initializes an instance of the class.

public CloneOptions()

Properties

CloneType

The desired type of the cloned object if it is not the same as the source object.

public Type? CloneType { get; set; }

Property Value

Type:

The desired Type of the cloned object, or null to use the default. The default value is null.

Remarks

The InstanceFactory, when defined and returning a non-null instance, will supersede this option.

IgnoreCloneableObjects

Whether objects which natively supporting cloning (e.g., ICloneable) should be able to clone themselves.

public bool IgnoreCloneableObjects { get; set; }

Property Value

bool:

true to create new, default instances of objects; false to allow the object to return its own clone (e.g., Clone()). The default value is false.

InstanceFactory

A function this is responsible for creating a new instance of the object, which will become the clone.

public Func<object?>? InstanceFactory { get; set; }

Property Value

Func<object>:

A Func<TResult>, or null to use the default activation logic. The default value is null.

Remarks

If this factory method is undefined or returns null, the default type activation logic will be used.

UseOriginalObjectWhenCloneUnavailable

Indicates if the original object should be returned for the clone when one could not otherwise be provided.

public bool UseOriginalObjectWhenCloneUnavailable { get; set; }

Property Value

bool:

true to allow the original object to be returned as a clone. false to return null when a clone is unavailable. The default value is true.

Inherited Members

Extension Methods