Ejemplo n.º 1
0
 /// <summary>
 /// Clones this collection (acting as a list) into the specified object by performing a deep copy
 /// if the elements implement <see cref="ICloneable"/>, otherwise a shallow copy is performed.
 /// </summary>
 /// <param name="clone">The object to clone this object into.</param>
 private void CloneIntoList(CloneableCollection clone)
 {
     foreach (object element in this.innerList)
     {
         object clonedElement = element;
         if (element is ICloneable)
         {
             clonedElement = ((ICloneable)element).Clone();
         }
         clone.innerList.Add(clonedElement);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Clones this object into the specified object by performing deep copy if the elements implement
 /// <see cref="ICloneable"/>, otherwise a shallow copy is performed.
 /// </summary>
 /// <param name="clone">The object to clone this object into.</param>
 protected void CloneInto(CloneableCollection clone)
 {
     if (this.innerList != null)
     {
         this.CloneIntoList(clone);
     }
     else if (this.innerDictionary != null)
     {
         this.CloneIntoDictionary(clone);
     }
     else
     {
         Tracer.Fail("The CloneableCollection is in an illegal state.");
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Clones this collection (acting as a dictionary) into the specified object by performing a deep copy
 /// if the elements implement <see cref="ICloneable"/>, otherwise a shallow copy is performed.
 /// </summary>
 /// <param name="clone">The object to clone this object into.</param>
 private void CloneIntoDictionary(CloneableCollection clone)
 {
     foreach (DictionaryEntry entry in this.innerDictionary)
     {
         object clonedKey   = entry.Key;
         object clonedValue = entry.Value;
         if (clonedKey is ICloneable)
         {
             clonedKey = ((ICloneable)clonedKey).Clone();
         }
         if (clonedValue is ICloneable)
         {
             clonedValue = ((ICloneable)clonedValue).Clone();
         }
         clone.innerDictionary.Add(clonedKey, clonedValue);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Clones this collection (acting as a list) into the specified object by performing a deep copy
 /// if the elements implement <see cref="ICloneable"/>, otherwise a shallow copy is performed.
 /// </summary>
 /// <param name="clone">The object to clone this object into.</param>
 private void CloneIntoList(CloneableCollection clone)
 {
     foreach (object element in this.innerList)
     {
         object clonedElement = element;
         if (element is ICloneable)
         {
             clonedElement = ((ICloneable)element).Clone();
         }
         clone.innerList.Add(clonedElement);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Clones this collection (acting as a dictionary) into the specified object by performing a deep copy
 /// if the elements implement <see cref="ICloneable"/>, otherwise a shallow copy is performed.
 /// </summary>
 /// <param name="clone">The object to clone this object into.</param>
 private void CloneIntoDictionary(CloneableCollection clone)
 {
     foreach (DictionaryEntry entry in this.innerDictionary)
     {
         object clonedKey = entry.Key;
         object clonedValue = entry.Value;
         if (clonedKey is ICloneable)
         {
             clonedKey = ((ICloneable)clonedKey).Clone();
         }
         if (clonedValue is ICloneable)
         {
             clonedValue = ((ICloneable)clonedValue).Clone();
         }
         clone.innerDictionary.Add(clonedKey, clonedValue);
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Clones this object into the specified object by performing deep copy if the elements implement
 /// <see cref="ICloneable"/>, otherwise a shallow copy is performed.
 /// </summary>
 /// <param name="clone">The object to clone this object into.</param>
 protected void CloneInto(CloneableCollection clone)
 {
     if (this.innerList != null)
     {
         this.CloneIntoList(clone);
     }
     else if (this.innerDictionary != null)
     {
         this.CloneIntoDictionary(clone);
     }
     else
     {
         Tracer.Fail("The CloneableCollection is in an illegal state.");
     }
 }