Ejemplo n.º 1
0
 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);
                }
            }
        }
Ejemplo n.º 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>());
            }
        }
Ejemplo n.º 4
0
        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);
                        }
                    }
                }
            }
        }