/// <summary> /// Add the babies stored in the Babies list to the main list. This is an /// internal method that may only be called by classes in the Rabies_Model_Core /// namespace. /// </summary> /// <param name="EHandler">An event handler for the AnimalInfected event.</param> internal void AddBabiesToList(AnimalInfectedEventHandler EHandler) { //System.Diagnostics.Debug.WriteLine(""); //System.Diagnostics.Debug.WriteLine("cMasterAnimalList.cs: AddBabiesToList()"); if (Babies.Count > 0) { // loop through all animals in the babies list foreach (cAnimal BabyAnimal in Babies) { // set the event handler if (EHandler != null) { BabyAnimal.AnimalInfected += EHandler; } // add to main list this.Add(BabyAnimal); // add to all animals list if (mvarKeepAllAnimals) { AllAnimals.Add(BabyAnimal); } } // destroy this version of the BabyAnimal list and create a new one Babies = new cAnimalList(null); } }
/// <summary> /// Set the handler for the AnimalInfected event for every animal in the list /// </summary> /// <param name="EHandler">The event handler for the AnimalInfected event.</param> internal void SetAnimalInfectedHandler(AnimalInfectedEventHandler EHandler) { // loop through all animals, setting the value foreach (cAnimal Animal in this) { Animal.AnimalInfected += EHandler; } }