public void AppendClone(SealableCollection <T> other) { if (typeof(ICloneable).IsAssignableFrom(typeof(T))) { foreach (var item in other) { this.Add((T)((ICloneable)item).Clone()); } } else { foreach (var item in other) { this.Add(item); } } }
public SealableCollection <T> Clone() { var collection = new SealableCollection <T>(); if (typeof(ICloneable).IsAssignableFrom(typeof(T))) { foreach (var item in _storage) { collection.Add((T)((ICloneable)item).Clone()); } } else { foreach (var item in _storage) { collection.Add(item); } } return(collection); }