Ejemplo n.º 1
0
        internal void Replace(string idToUpdate, Rock rock)
        {
            if (rock == null)
            {
                throw new ArgumentNullException("rock");
            }

            int index = IndexOf(idToUpdate);

            if (index == -1)
            {
                throw new ArgumentException("Supplied ID not found in collection.");
            }

            //Remove the rock from the collection.

            Rocks.RemoveAt(index);

            //Verify the (possibly changed) ID not in collection already
            if (IndexOf(rock.UniqueId) != -1)
            {
                throw new ArgumentException("A rock with the specified ID already exists in the collection.");
            }


            //Insert the new rock at the same place.
            Rocks.Insert(index, rock);
        }