Ejemplo n.º 1
0
 private void AddFaultDetails(ValidationFault fault, string parameterName, ValidationResults results)
 {
     if (!results.IsValid)
     {
         foreach (ValidationResult result in results)
         {
             fault.Add(CreateValidationDetail(result, parameterName));
         }
     }
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="operationName"></param>
        /// <param name="inputs"></param>
        /// <returns></returns>
        public object BeforeCall(string operationName, object[] inputs)
        {
            ValidationFault fault = new ValidationFault();
            for (int i = 0; i < inputValidators.Count; ++i)
            {
                ValidationResults results = inputValidators[i].Validate(inputs[i]);
                AddFaultDetails(fault, inputValidatorParameterNames[i], results);
            }

            if (!fault.IsValid)
            {
                throw new FaultException<ValidationFault>(fault);
            }

            return null;
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="operationName"></param>
        /// <param name="inputs"></param>
        /// <returns></returns>
        public object BeforeCall(string operationName, object[] inputs)
        {
            ValidationFault fault = new ValidationFault();

            for (int i = 0; i < inputValidators.Count; ++i)
            {
                ValidationResults results = inputValidators[i].Validate(inputs[i]);
                AddFaultDetails(fault, inputValidatorParameterNames[i], results);
            }

            if (!fault.IsValid)
            {
                throw new FaultException <ValidationFault>(fault);
            }

            return(null);
        }
 private void AddFaultDetails(ValidationFault fault, string parameterName, ValidationResults results)
 {
     if (!results.IsValid)
     {
         foreach (ValidationResult result in results)
         {
             fault.Add(CreateValidationDetail(result, parameterName));
         }
     }
 }