private static Validator <T> CreateValidator <T>(string ruleset, bool cacheValidator)
        {
            Validator <T> validator = null;

            if (cacheValidator)
            {
                object obj;
                Monitor.Enter(obj = ValidationFactory.attributeAndDefaultConfigurationValidatorsCacheLock);
                try
                {
                    ValidationFactory.ValidatorCacheKey key = new ValidationFactory.ValidatorCacheKey(typeof(T), ruleset, true);
                    Validator validator2;
                    if (ValidationFactory.attributeAndDefaultConfigurationValidatorsCache.TryGetValue(key, out validator2))
                    {
                        return((Validator <T>)validator2);
                    }
                    Validator validator3 = ValidationFactory.InnerCreateValidatorFromAttributes(typeof(T), ruleset);
                    validator = ValidationFactory.WrapAndInstrumentValidator <T>(validator3);
                    ValidationFactory.attributeAndDefaultConfigurationValidatorsCache[key] = validator;
                    return(validator);
                }
                finally
                {
                    Monitor.Exit(obj);
                }
            }
            Validator validator4 = ValidationFactory.InnerCreateValidatorFromAttributes(typeof(T), ruleset);

            validator = ValidationFactory.WrapAndInstrumentValidator <T>(validator4);
            return(validator);
        }
        public static Validator <T> CreateValidatorFromAttributes <T>(string ruleset)
        {
            if (ruleset == null)
            {
                throw new ArgumentNullException("ruleset");
            }
            Validator <T> validator = null;
            object        obj;

            Monitor.Enter(obj = ValidationFactory.attributeOnlyValidatorsCacheLock);
            try
            {
                ValidationFactory.ValidatorCacheKey key = new ValidationFactory.ValidatorCacheKey(typeof(T), ruleset, true);
                Validator validator2;
                if (ValidationFactory.attributeOnlyValidatorsCache.TryGetValue(key, out validator2))
                {
                    return((Validator <T>)validator2);
                }
                Validator validator3 = ValidationFactory.InnerCreateValidatorFromAttributes(typeof(T), ruleset);
                validator = ValidationFactory.WrapAndInstrumentValidator <T>(validator3);
                ValidationFactory.attributeOnlyValidatorsCache[key] = validator;
            }
            finally
            {
                Monitor.Exit(obj);
            }
            return(validator);
        }
        public static Validator CreateValidatorFromAttributes(Type targetType, string ruleset)
        {
            if (ruleset == null)
            {
                throw new ArgumentNullException("ruleset");
            }
            Validator validator = null;
            object    obj;

            Monitor.Enter(obj = ValidationFactory.attributeOnlyValidatorsCacheLock);
            try
            {
                ValidationFactory.ValidatorCacheKey key = new ValidationFactory.ValidatorCacheKey(targetType, ruleset, false);
                Validator result;
                if (ValidationFactory.attributeOnlyValidatorsCache.TryGetValue(key, out result))
                {
                    return(result);
                }
                Validator validator2 = ValidationFactory.InnerCreateValidatorFromAttributes(targetType, ruleset);
                validator = ValidationFactory.WrapAndInstrumentValidator(validator2);
                ValidationFactory.attributeOnlyValidatorsCache[key] = validator;
            }
            finally
            {
                Monitor.Exit(obj);
            }
            return(validator);
        }
        private static Validator CreateValidator(Type targetType, string ruleset, bool cacheValidator)
        {
            Validator validator = null;

            if (cacheValidator)
            {
                object obj;
                Monitor.Enter(obj = ValidationFactory.attributeAndDefaultConfigurationValidatorsCacheLock);
                try
                {
                    ValidationFactory.ValidatorCacheKey key = new ValidationFactory.ValidatorCacheKey(targetType, ruleset, false);
                    Validator result;
                    if (ValidationFactory.attributeAndDefaultConfigurationValidatorsCache.TryGetValue(key, out result))
                    {
                        return(result);
                    }
                    Validator validator2 = ValidationFactory.InnerCreateValidatorFromAttributes(targetType, ruleset);
                    validator = ValidationFactory.WrapAndInstrumentValidator(validator2);
                    ValidationFactory.attributeAndDefaultConfigurationValidatorsCache[key] = validator;
                    return(validator);
                }
                finally
                {
                    Monitor.Exit(obj);
                }
            }
            Validator validator3 = ValidationFactory.InnerCreateValidatorFromAttributes(targetType, ruleset);

            validator = ValidationFactory.WrapAndInstrumentValidator(validator3);
            return(validator);
        }