private void OnSimulationCommencing(object sender, EventArgs e) { // locate OtherAnimalsType resource bool resourceAvailable = false; animalType = Resources.GetResourceItem("OtherAnimals", OtherAnimalType, out resourceAvailable) as OtherAnimalsType; }
private void OnSimulationCommencing(object sender, EventArgs e) { SelectedOtherAnimalsType = Resources.OtherAnimalsStore().GetByName(AnimalType) as OtherAnimalsType; if (SelectedOtherAnimalsType == null) { throw new Exception("Unknown other animal type: " + AnimalType + " in OtherAnimalsActivityFeed : " + this.Name); } if (BreedingInterval <= 0) { Summary.WriteWarning(this, String.Format("Overhead payment interval must be greater than 1 ({0})", this.Name)); throw new Exception(String.Format("Invalid payment interval supplied for overhead {0}", this.Name)); } if (StartBreedingMonth >= Clock.StartDate.Month) { NextDueDate = new DateTime(Clock.StartDate.Year, StartBreedingMonth, Clock.StartDate.Day); } else { NextDueDate = new DateTime(Clock.StartDate.Year, StartBreedingMonth, Clock.StartDate.Day); while (Clock.StartDate > NextDueDate) { NextDueDate = NextDueDate.AddMonths(BreedingInterval); } } }
private void OnSimulationCommencing(object sender, EventArgs e) { SelectedOtherAnimalsType = Resources.OtherAnimalsStore().FindChild(AnimalType) as OtherAnimalsType; if (SelectedOtherAnimalsType == null) { throw new Exception("Unknown other animal type: " + AnimalType + " in OtherAnimalsActivityFeed : " + this.Name); } }
/// <summary> /// Object validation /// </summary> /// <param name="validationContext"></param> /// <returns></returns> public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var results = new List <ValidationResult>(); SelectedOtherAnimalsType = Resources.OtherAnimalsStore().GetByName(AnimalType) as OtherAnimalsType; if (SelectedOtherAnimalsType == null) { string[] memberNames = new string[] { "AnimalType" }; results.Add(new ValidationResult("Unknown other animal type: " + AnimalType, memberNames)); } return(results); }
private void OnCLEMInitialiseActivity(object sender, EventArgs e) { // locate OtherAnimalsType resource animalType = Resources.GetResourceItem(this, OtherAnimalType, OnMissingResourceActionTypes.ReportErrorAndStop, OnMissingResourceActionTypes.ReportErrorAndStop) as OtherAnimalsType; }
private void OnCLEMInitialiseActivity(object sender, EventArgs e) { // get other animal type model SelectedOtherAnimalsType = Resources.FindResourceType <OtherAnimals, OtherAnimalsType>(this, AnimalType, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.Ignore); }