In the EntLib 5.0 validation block, when using the ValidatorRule provided by the Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WPF library, I would like to be able to specify an implementation of IConfigurationSource to use. When not
integrating directly with WPF we are able to do this in code as follows:
string configFilePath = @"ClientValidation.xml";
var configurationSource = new FileConfigurationSource(configFilePath);
var configurationValidatorFactory = ConfigurationValidatorFactory.FromConfigurationSource(configurationSource);
var validator = configurationValidatorFactory.CreateValidator<T>();
var validationResults = validator.Validate(obj);
But how do we specify that same instance of IConfigurationSource when using the WPF ValidatorRule?
I've tried something like this - in our bootstrapper:
UnityContainerConfigurator unityContainerConfigurator = new UnityContainerConfigurator(OurUnityContainer);
But that configurationSource doesn't seem to be used by the WPF validator. And in looking at the EntLib 5.0 source, it seems that the WPF ValidatorRule is pulling the rules/rulesets out of app.config - by using the .NET ConfigurationManager. But I don't
see any way of altering the IConfigurationSource???
Ultimately, I want to be able to specify the file from which to pull validation configuration - as the code above does - when using the WPF ValidatorRule.
Thanks for your input.