Beispiel #1
0
        /// <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>
 /// Adds the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 public void Add(V value) => _dictionary.Add(value.GetType(), value);