示例#1
0
		/// <summary>
		/// Performs the validation test
		/// </summary>
		/// <returns></returns>
		protected override ColladaValidationException ValidateImpl()
		{
			// if the field is null, return an exception
			ColladaValidationException exception = null;
			if (testField.GetValue() == null)
				exception = new ColladaValidationException(
					String.Format(exceptionFormat, "IsNull", testField.GetTypeName(), "a required element is null"));
			return exception;
		}
示例#2
0
        /// <summary>
        /// Performs the validation test
        /// </summary>
        /// <returns></returns>
        protected override ColladaValidationException ValidateImpl()
        {
            // if the field is null, return an exception
            ColladaValidationException exception = null;

            if (testField.GetValue() == null)
            {
                exception = new ColladaValidationException(
                    String.Format(exceptionFormat, "IsNull", testField.GetTypeName(), "a required element is null"));
            }
            return(exception);
        }
示例#3
0
		/// <summary>
		/// Performs the validation test
		/// </summary>
		/// <returns></returns>
		protected override ColladaValidationException ValidateImpl()
		{
			ColladaValidationException exception = null;

			// find out homw many fields in the list are not null
			int value_count = 0;
			foreach (var field in _testFields)
				value_count += ((field.GetValue() != null) ? 1 : 0);

			// if all the fields are null return an exception
			if (value_count == 0)
				exception = new ColladaValidationException(
					String.Format(exceptionFormat, "OneRequired", "N//A", "a required element is missing"));
			return exception;
		}
		/// <summary>
		/// Performs the validation test
		/// </summary>
		/// <returns></returns>
		protected override ColladaValidationException ValidateImpl()
		{
			ColladaValidationException exception = null;

			// check if any of the invalid fields are not null
			bool invalid = false;
			for (int i = 0; (i < testFields.Count) && !invalid; i++)
				invalid = testFields[i].GetValue() != null;

			// in an invalid field was present, return an exception
			if (invalid)
				exception = new ColladaValidationException(
					String.Format(exceptionFormat, "InvalidForParent", "N//A", "an element is present that is not valid for its parent"));
			return exception;
		}
		/// <summary>
		/// Performs the validation test
		/// </summary>
		/// <returns></returns>
		protected override ColladaValidationException ValidateImpl()
		{
			ColladaValidationException exception = null;

			// get the number of elements in the list that are not null
			int value_count = 0;
			foreach (var field in testFields)
				value_count += ((field.GetValue() != null) ? 1 : 0);

			// if the value is more than 1 return an exception
			if (value_count > 1)
				exception = new ColladaValidationException(
					String.Format(exceptionFormat, "MutuallyExclusive", "N//A", "an element list does not have the minimum number of elements"));
			return exception;
		}
示例#6
0
		/// <summary>
		/// Performs the validation test
		/// </summary>
		/// <returns></returns>
		protected override ColladaValidationException ValidateImpl()
		{
			// get the string value
			string test_string = (testField.GetValue() as string);

			// if the value is null, return null
			// there is a specific null value validation test for checking this
			if (test_string == null)
				return null;

			ColladaValidationException exception = null;
			if (test_string.Length == 0)
			{
				exception = new ColladaValidationException(
					String.Format(exceptionFormat, "EmptyString", testField.GetTypeName(), "a necessary strings length is zero"));
			}
			return exception;
		}
        /// <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()
		{
			ColladaValidationException exception = null;

			// determine whether one or more fields exists without the others
			bool any_present = false;
			bool all_present = true;
			foreach (var field in _testFields)
			{
				all_present &= (field.GetValue() != null);
				any_present |= (field.GetValue() != null);
			}

			// if an element is missing, when at least one is present, return an exception
			if (any_present && !all_present)
				exception = new ColladaValidationException(
					String.Format(exceptionFormat, "MutuallyInclusive", "N//A", "one or more elements missing that are mutually inclusive"));
			return exception;
		}
        /// <summary>
        /// Performs the validation test
        /// </summary>
        /// <returns></returns>
        protected override ColladaValidationException ValidateImpl()
        {
            ColladaValidationException exception = null;

            // get the number of elements in the list that are not null
            int value_count = 0;

            foreach (var field in testFields)
            {
                value_count += ((field.GetValue() != null) ? 1 : 0);
            }

            // if the value is more than 1 return an exception
            if (value_count > 1)
            {
                exception = new ColladaValidationException(
                    String.Format(exceptionFormat, "MutuallyExclusive", "N//A", "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()
        {
            ColladaValidationException exception = null;

            // check if any of the invalid fields are not null
            bool invalid = false;

            for (int i = 0; (i < testFields.Count) && !invalid; i++)
            {
                invalid = testFields[i].GetValue() != null;
            }

            // in an invalid field was present, return an exception
            if (invalid)
            {
                exception = new ColladaValidationException(
                    String.Format(exceptionFormat, "InvalidForParent", "N//A", "an element is present that is not valid for its parent"));
            }
            return(exception);
        }
        /// <summary>
        /// Performs the validation test
        /// </summary>
        /// <returns></returns>
        protected override ColladaValidationException ValidateImpl()
        {
            ColladaValidationException exception = null;

            // find out homw many fields in the list are not null
            int value_count = 0;

            foreach (var field in _testFields)
            {
                value_count += ((field.GetValue() != null) ? 1 : 0);
            }

            // if all the fields are null return an exception
            if (value_count == 0)
            {
                exception = new ColladaValidationException(
                    String.Format(exceptionFormat, "OneRequired", "N//A", "a required element is missing"));
            }
            return(exception);
        }
        /// <summary>
        /// Performs the validation test
        /// </summary>
        /// <returns></returns>
        protected override ColladaValidationException ValidateImpl()
        {
            // get the string value
            string test_string = (testField.GetValue() as string);

            // if the value is null, return null
            // there is a specific null value validation test for checking this
            if (test_string == null)
            {
                return(null);
            }

            ColladaValidationException exception = null;

            if (test_string.Length == 0)
            {
                exception = new ColladaValidationException(
                    String.Format(exceptionFormat, "EmptyString", testField.GetTypeName(), "a necessary strings length is zero"));
            }
            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);
        }
        /// <summary>
        /// Performs the validation test
        /// </summary>
        /// <returns></returns>
        protected override ColladaValidationException ValidateImpl()
        {
            ColladaValidationException exception = null;

            // determine whether one or more fields exists without the others
            bool any_present = false;
            bool all_present = true;

            foreach (var field in _testFields)
            {
                all_present &= (field.GetValue() != null);
                any_present |= (field.GetValue() != null);
            }

            // if an element is missing, when at least one is present, return an exception
            if (any_present && !all_present)
            {
                exception = new ColladaValidationException(
                    String.Format(exceptionFormat, "MutuallyInclusive", "N//A", "one or more elements missing that are mutually inclusive"));
            }
            return(exception);
        }
        /// <summary>
        /// Performs the validation test
        /// </summary>
        /// <returns></returns>
        protected override ColladaValidationException ValidateImpl()
        {
            // get the value of the field
            T value = (T)testField.GetValue();

            // if the value is null, return null
            // there is a specific null value validation test for checking this
            if (value == null)
            {
                return(null);
            }

            // if the valid value list does not have the current value return an exception
            ColladaValidationException exception = null;

            if (!validValues.Contains(value))
            {
                exception = new ColladaValidationException(
                    String.Format(exceptionFormat, "HasValidValue", testField.GetTypeName(), "an element has an invalid value"));
            }
            return(exception);
        }
示例#16
0
        /// <summary>
        /// Runs the validation test
        /// </summary>
        /// <param name="parent_type">The parent element type, used to determine whether this test needs to be run</param>
        /// <returns></returns>
        public ColladaValidationException Validate(Enums.ColladaElementType parent_type)
        {
            bool valid_parent = false;

            // if the test should be run with any parent type, valid_parent will be true
            if (_validParentType == Enums.ColladaElementType.All)
            {
                valid_parent = true;
            }
            else
            {
                valid_parent = (parent_type == _validParentType);
            }

            // validate the field and return an exception if necessary
            ColladaValidationException exception = null;

            if (valid_parent)
            {
                exception = ValidateImpl();
            }
            return(exception);
        }