/// <inheritdoc/> ICloneable ICloneable.Clone() { var clone = new InheritedTypeDictionary <V>(); foreach (var pair in _dictionary) { // Only add direct elements if (pair.Value.IsDirect) { var cloned = pair.Value.Value; if (cloned is ICloneable cloneable) { cloned = (V)cloneable.Clone(); } clone.Add(pair.Key, cloned); } } return(clone); }
/// <summary> /// Initializes a new instance of the <see cref="InheritedTypeSet{V}"/> class. /// </summary> public InheritedTypeSet() { _dictionary = new InheritedTypeDictionary <V>(); }
/// <summary> /// Initializes a new instance of the <see cref="InheritedTypeSet{V}"/> class. /// </summary> /// <param name="original">The original.</param> protected InheritedTypeSet(InheritedTypeSet <V> original) { _dictionary = (InheritedTypeDictionary <V>)((ICloneable)original._dictionary).Clone(); }