/// <summary> /// Performs the validation test /// </summary> /// <returns></returns> protected override ColladaValidationException ValidateImpl() { // if the value is null, return null // there is a specific null value validation test for checking this if (testField.Value == null) { return(null); } // if the list does no have the minimum number of elements, return an exception ColladaValidationException exception = null; if (testField.Value.Count < minimumCount) { exception = new ColladaValidationException( String.Format(exceptionFormat, "ListMinCount", testField.GetTypeName(), "an element list does not have the minimum number of elements")); } return(exception); }
/// <summary> /// Performs the validation test /// </summary> /// <returns></returns> protected override ColladaValidationException ValidateImpl() { // gets the property info of the specified property in the element type // if null, the implimentation of this test is wrong PropertyInfo property = typeof(T1).GetProperty(propertyName); if (property == null) { return(null); } if (testField.Value == null) { return(null); } // loop though the fields elements bool has_value = false; for (int i = 0; (i < testField.Value.Count) && !has_value; i++) { T2 element_value = (T2)property.GetValue(testField.Value[i], null); if (element_value == null) { continue; } has_value = element_value.Equals(requiredValue); } // if the required value was not found, return an exception ColladaValidationException exception = null; if (!has_value) { exception = new ColladaValidationException( String.Format(exceptionFormat, "ListHasValue", testField.GetTypeName(), "a list of elements is missing a necessary value")); } return(exception); }