/// <summary> /// Validate this object /// </summary> /// <param name="validationContext"></param> /// <returns></returns> public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var results = new List <ValidationResult>(); if (ResourceTypeName != null && ResourceTypeName != "") { if (!ResourceTypeName.Contains(".")) { string[] memberNames = new string[] { "ResourceTypeName" }; results.Add(new ValidationResult("Invalid resource type entry. Please select resource type from the drop down list provided or ensure the value is formatted as ResourceGroup.ResourceType", memberNames)); } else { object result = Resources.GetResourceGroupByName(ResourceTypeName.Split('.').First()); if (result == null) { string[] memberNames = new string[] { "ResourceGroup" }; results.Add(new ValidationResult("Could not find resource [r=" + ResourceTypeName.Split('.').First() + "] in transmutation cost", memberNames)); } else { object resultType = Resources.GetResourceItem(this, ResourceTypeName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.Ignore); if (resultType is null) { string[] memberNames = new string[] { "ResourceType" }; results.Add(new ValidationResult($"Could not find resource [r={ResourceTypeName.Split('.').First()}][r={ResourceTypeName.Split('.').Last()}] in transmutation cost", memberNames)); } } } } return(results); }
private void OnStartOfSimulation(object sender, EventArgs e) { // determine resource type from name object result = Resources.GetResourceGroupByName(ResourceTypeName.Split('.').First()); ResourceType = result.GetType(); }