Split Validation config into Second Config file

Topics: Validation Application Block
Nov 25, 2008 at 5:04 PM
Hello,

I am using the Validation block and entering my RegEx for the validation block into the config file, however i'm wondering if the Validation block config can be placed in a seperate configuration file completley. To keep my App.config nice and clean.

Cheers,
Rob
Nov 25, 2008 at 11:44 PM
You can have as much configuration file as you like.  Doing so would require you to use an IConfigurationSource in order for your code to read the correct configuration file. Here's a sample code.

IConfigurationSource configurationSource = new FileConfigurationSource("validation.config");

 

 

Validator<Foo> fooValidator = ValidationFactory.CreateValidator(typeof(Foo), "RuleSet", configurationSource) as Validator<Foo>;

 


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com

 

 

Nov 27, 2008 at 5:27 PM
Thank you so much, this hit the nail on the head! Many thanks!
Feb 20, 2009 at 8:24 AM
Hi!

I have a related question. Is it possible to construct the validator from multiple configuration files?
My case is that I want to have one private configuration that others can't change, and one public - open for modifications.

Thank you in advance for the response.
Bartek.
Feb 20, 2009 at 11:38 AM
There's no direct support for this.  But what you could do is call validation for each configuration source.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com

 

Feb 20, 2009 at 11:50 AM
Thank you for this quick response.

Bartek.