Class DeepCloner
- Namespace
- Terminal.Gui.Configuration
- Assembly
- Terminal.Gui.dll
Provides deep cloning functionality for Terminal.Gui configuration objects. Creates a deep copy of an object by recursively cloning public properties, handling collections, arrays, dictionaries, and circular references.
public static class DeepCloner
- Inheritance
-
DeepCloner
- Inherited Members
Remarks
This class does not use ICloneable because it does not guarantee deep cloning, may not handle circular references, and is not widely implemented in modern .NET types. Instead, it uses reflection to ensure consistent deep cloning behavior across all types.
Limitations: - Types without a parameterless constructor (and not handled as simple types, arrays, dictionaries, or collections) may be instantiated using uninitialized objects, which could lead to runtime errors if not properly handled. - Immutable collections (e.g., ImmutableDictionary<TKey, TValue>) are not supported and will throw a NotSupportedException. - Only public, writable properties are cloned; private fields, read-only properties, and non-public members are ignored.
Methods
- DeepClone<T>(T?)
Creates a deep copy of the specified object.