Exemplo n.º 1
0
 public void Add(TisValidationsResult validationResult)
 {
     foreach (KeyValuePair <TisValidationMethod, TisValidationMethodResult> kpv in validationResult)
     {
         Add(kpv.Key, kpv.Value);
     }
 }
Exemplo n.º 2
0
        public static ValidationStatus GetFinalValidationStatus(
            TisValidationsResult results,
            ValidationResultPolicy resultPolicy)
        {
            ValidationStatus finalValidationsStatus =
                GetFinalValidationResult(results.Values, resultPolicy);

            ((TisValidationsResult)results).SetFinalValidationsStatus(finalValidationsStatus);

            return(finalValidationsStatus);
        }
        public ValidationStatus Validate(
            TisValidationPolicy validationPolicy,
            TisValidationsResult validationsResult)
        {
            ((TisValidationsResult)validationsResult).Clear();

            ValidationStatus validationStatus = m_validationManager.Validate(
                m_validators,
                validationPolicy,
                validationsResult);

            return(validationStatus);
        }
Exemplo n.º 4
0
        public TisValidationsResult FilterBy(TisValidationsResultFilter filter)
        {
            TisValidationsResult finalValidationsResult = new TisValidationsResult();

            foreach (KeyValuePair <TisValidationMethod, TisValidationMethodResult> kpv in this)
            {
                if (filter.Accepts(kpv.Key, kpv.Value))
                {
                    finalValidationsResult.Add(kpv.Key, kpv.Value);
                }
            }

            return(finalValidationsResult);
        }
Exemplo n.º 5
0
        public ValidationStatus Validate(
            List <TisValidator> validators,
            TisValidationPolicy validationPolicy,
            TisValidationsResult validationsResult)
        {
            foreach (TisValidator validator in validators)
            {
                ValidationStatus lastValidationStatus = Validate(
                    validator.ValidationsProvider,
                    validator.ValidationsSource,
                    validator.ValidationTarget,
                    validationPolicy,
                    validationsResult);

                if (ShouldStopValidation(lastValidationStatus, validationPolicy.StopPolicy, validationPolicy.ResultPolicy))
                {
                    return(ValidationStatus.Invalid);
                }
            }

            return(TisValidationsResult.GetFinalValidationStatus(
                       validationsResult,
                       validationPolicy.ResultPolicy));
        }
Exemplo n.º 6
0
 private TisValidationsResult(TisValidationsResult me)
 {
     m_dict = new Dictionary <TisValidationMethod, TisValidationMethodResult>(me.m_dict);
 }
Exemplo n.º 7
0
        public ValidationStatus Validate(
            ITisValidationProvider validationsProvider,
            TisValidationsSource validationsSource,
            object validationsTarget,
            TisValidationPolicy validationPolicy,
            TisValidationsResult validationsResult)
        {
            if (validationsSource == null)
            {
                throw new TisException("Validations source does not exist.");
            }

            if (validationsResult == null)
            {
                throw new TisException("Validations result is not allocated.");
            }

            ParallelCall parallelCall = new ParallelCall();

            List <TisValidationMethod> supportedValidations =
                GetSupportedValidations(validationsProvider);

            parallelCall.ThreadsToUse = supportedValidations.Count;

            TisValidationMethodResult  validationMethodResult;
            List <TisValidationMethod> performedValidations = new List <TisValidationMethod>();

            List <ITisValidationContext> validationContexts =
                m_validationContextMngr.GetValidationContextsByType(validationsSource.ValidationType);

            foreach (TisValidationMethod supportedValidation in supportedValidations)
            {
                if (IsValidationConfirmed(supportedValidation, validationContexts))
                {
                    if (validationPolicy.RunPolicy == ValidationRunPolicy.Sync)
                    {
                        validationMethodResult = ExecuteValidationMethod(
                            supportedValidation,
                            validationsSource.Source,
                            validationsTarget,
                            validationContexts);

                        validationsResult.Add(supportedValidation, validationMethodResult);

                        if (ShouldStopValidation(
                                validationMethodResult.Status,
                                validationPolicy.StopPolicy,
                                validationPolicy.ResultPolicy))
                        {
                            break;
                        }
                    }
                    else
                    {
                        performedValidations.Add(supportedValidation);

                        parallelCall.Add(
                            new ExecuteValidationMethodDelegate(ExecuteValidationMethod),
                            new object[] { supportedValidation,
                                           validationsSource.Source,
                                           validationsTarget,
                                           validationContexts });
                    }
                }
                else
                {
                    parallelCall.ThreadsToUse--;
                }
            }

            if (validationPolicy.RunPolicy == ValidationRunPolicy.Async)
            {
                object[] asyncValidationResults = parallelCall.Perform(true);

                for (int i = 0; i < performedValidations.Count; i++)
                {
                    validationsResult.Add(performedValidations[i], (TisValidationMethodResult)asyncValidationResults[i]);
                }
            }

            return(TisValidationsResult.GetFinalValidationStatus(
                       validationsResult,
                       validationPolicy.ResultPolicy));
        }