예제 #1
0
 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);
         }
     }
 }
예제 #2
0
        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);
        }