Settings
Defaults copy public and non-public properties and fields, and will use non-public constructors when needed. Override what you need via CloneSettings.
Passing settings
var clone = source.CloneX(new CloneSettings {
IncludeNonPublicFields = false,
IncludeNonPublicProperties = false,
UseICloneableClone = true,
Logger = logger // Microsoft.Extensions.Logging
});The same object works with CloneXTo():
source.CloneXTo(target, settings);Visibility
| Setting | Default | Meaning |
|---|---|---|
IncludePublicProperties | true | Copy public properties |
IncludeNonPublicProperties | true | Copy non-public properties |
IncludePublicFields | true | Copy public fields |
IncludeNonPublicFields | true | Copy non-public fields |
IncludePublicConstructors | true | Allow public constructors when creating instances |
IncludeNonPublicConstructors | true | Allow non-public constructors when needed |
ICloneable
ICloneable is ignored unless you opt in:
UseICloneableClone = trueWhen enabled, CloneBox may call ICloneable.Clone() for types that implement it.
Skip predicates
See
Skip members for DoNotCloneProperty, DoNotCloneField, and DoNotCloneClass.
Logging
Set Logger to an ILogger from Microsoft.Extensions.Logging if you want diagnostics while cloning.
Prev
Skip MembersNext
Benchmarks