/// <summary> /// /// </summary> /// <param name="objectToValidate"></param> /// <param name="currentTarget"></param> /// <param name="key"></param> /// <param name="validationResults"></param> protected override void DoValidate(T objectToValidate, object currentTarget, string key, ValidationResults validationResults) { Type typeBeingValidated = typeof(T); instrumentationProvider.NotifyConfigurationCalled(typeBeingValidated); try { this.WrappedValidator.DoValidate(objectToValidate, currentTarget, key, validationResults); if (validationResults.IsValid) { instrumentationProvider.NotifyValidationSucceeded(typeBeingValidated); } else { instrumentationProvider.NotifyValidationFailed(typeBeingValidated, validationResults); } } catch (ConfigurationErrorsException configurationErrors) { instrumentationProvider.NotifyConfigurationFailure(configurationErrors); throw; } catch (Exception ex) { instrumentationProvider.NotifyValidationException(typeBeingValidated, ex.Message, ex); throw; } }
private ValidatedTypeReference GetTypeReference(Type type) { try { if (null == validationSettings) { return(null); } ValidatedTypeReference typeReference = validationSettings.Types.Get(type.FullName); return(typeReference); } catch (ConfigurationErrorsException configurationErrors) { instrumentationProvider.NotifyConfigurationFailure(configurationErrors); throw; } }
///<summary> /// Tries to retrieve the <see cref="ValidationSettings"/> and notifies the provided <see cref="IValidationInstrumentationProvider"/> /// if there is a <see cref="ConfigurationErrorsException"/>. The exception is rethrown. ///</summary> ///<param name="configurationSource"></param> ///<param name="instrumentationProvider"></param> ///<returns></returns> public static ValidationSettings TryGet( IConfigurationSource configurationSource, IValidationInstrumentationProvider instrumentationProvider ) { if (configurationSource == null) throw new ArgumentNullException("configurationSource"); if (instrumentationProvider == null) throw new ArgumentNullException("instrumentationProvider"); try { return configurationSource.GetSection(ValidationSettings.SectionName) as ValidationSettings; } catch(ConfigurationErrorsException e) { instrumentationProvider.NotifyConfigurationFailure(e); throw; } }
///<summary> /// Tries to retrieve the <see cref="ValidationSettings"/> and notifies the provided <see cref="IValidationInstrumentationProvider"/> /// if there is a <see cref="ConfigurationErrorsException"/>. The exception is rethrown. ///</summary> ///<param name="configurationSource"></param> ///<param name="instrumentationProvider"></param> ///<returns></returns> public static ValidationSettings TryGet( IConfigurationSource configurationSource, IValidationInstrumentationProvider instrumentationProvider ) { if (configurationSource == null) { throw new ArgumentNullException("configurationSource"); } if (instrumentationProvider == null) { throw new ArgumentNullException("instrumentationProvider"); } try { return(configurationSource.GetSection(ValidationSettings.SectionName) as ValidationSettings); } catch (ConfigurationErrorsException e) { instrumentationProvider.NotifyConfigurationFailure(e); throw; } }