public void AddValidator(TisValidator validator)
 {
     if (!m_validators.Contains(validator))
     {
         m_validators.Add(validator);
     }
 }
        private void ObtainAllValidators()
        {
            string[] validationServiceProviderNames = TisServicesUtil.GetServicesOfImplType(
                m_serviceRegistry,
                typeof(ITisSupportValidation));

            foreach (string validationServiceProviderName in validationServiceProviderNames)
            {
                TisValidator validator =
                    (TisValidator)GetService(TisServicesSchema.Validator, validationServiceProviderName);

                if (validator != null)
                {
                    Type validationType = validator.ValidationType;

                    if (validationType != null)
                    {
                        TisValidator parentValidator = null;

                        m_allApplicationValidators.TryGetValue(validationType, out parentValidator);

                        if (parentValidator != null)
                        {
                            parentValidator.AddValidator(validator);
                        }
                        else
                        {
                            m_allApplicationValidators.Add(validationType, validator);
                        }
                    }
                    else
                    {
                        Log.WriteWarning("Installed validation service [{0}] does not provide validation target type", validationServiceProviderName);
                    }
                }
                else
                {
                    Log.WriteWarning("Validation service [{0}] is not installed", validationServiceProviderName);
                }
            }

            foreach (TisValidator validator in m_allApplicationValidators.Values)
            {
                try
                {
                    ((TisValidator)validator).Sort();
                }
                catch (Exception exc)
                {
                    Log.WriteException(Log.Severity.INFO, exc);
                }
            }
        }
Example #3
0
        public List <TisValidationMethod> GetSupportedValidationsByType(Type validationType)
        {
            TisValidator validator =
                m_validatorMngr.GetValidatorByType(validationType);

            if (validator != null)
            {
                return(validator.SupportedValidations);
            }
            else
            {
                return(new List <TisValidationMethod>());
            }
        }
        public int CompareTo(object obj)
        {
            TisValidator validator = (TisValidator)obj;

            int this_fromSchema      = 0;
            int validator_fromSchema = 0;

            if (this.ValidationsProvider is ITisServiceInfo && validator.ValidationsProvider is ITisServiceInfo)
            {
                this_fromSchema      = Convert.ToInt32((this.ValidationsProvider as ITisServiceInfo).FromSchema);
                validator_fromSchema = Convert.ToInt32((validator.ValidationsProvider as ITisServiceInfo).FromSchema);
            }

            if (this_fromSchema > validator_fromSchema)
            {
                // Build-in service will validate first
                return(-1);
            }
            else
            {
                if (this_fromSchema < validator_fromSchema)
                {
                    // Build-in service will validate first
                    return(1);
                }
                else
                {
                    if (this.ValidationsSource.Order > validator.ValidationsSource.Order)
                    {
                        return(1);
                    }
                    else
                    {
                        if (this.ValidationsSource.Order < validator.ValidationsSource.Order)
                        {
                            return(-1);
                        }
                        else
                        {
                            return(0);
                        }
                    }
                }
            }
        }