public TisValidator( TisInternalValidationManager validationManager, ITisValidationProvider validationsProvider) { m_validationManager = validationManager; m_validationsProvider = validationsProvider; m_validationsSource = m_validationManager.GetValidationsSource(m_validationsProvider); m_validators.Add(this); }
public void Dispose() { m_validationsProvider = null; m_validationsSource = null; m_validationTarget = null; if (m_validators != null) { foreach (TisValidator validator in m_validators) { if (!validator.Equals(this)) { validator.Dispose(); } } m_validators.Clear(); m_validators = null; } }
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)); }