Is FileConfigurationSource thread-safe?

Topics: Enterprise Library Core, Validation Application Block
Mar 20, 2009 at 11:36 AM
<style> <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-ansi-language:EN-US;} a:link, span.MsoHyperlink {color:blue; text-decoration:underline; text-underline:single;} a:visited, span.MsoHyperlinkFollowed {color:purple; text-decoration:underline; text-underline:single;} @page Section1 {size:595.3pt 841.9pt; margin:70.85pt 70.85pt 70.85pt 70.85pt; mso-header-margin:35.4pt; mso-footer-margin:35.4pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style>

I'm using the FileConfigurationSource to allow placing the configuration for the Validation Application Block in a separate configuration file (as discussed in this thread). In my application a FileConfigurationSource instance is created once per app domain and it is stored in a static field. The FileConfigurationSource lacks any documentation and I'm actually not sure if this is the correct usage of this type, so my question is: Is the FileConfigurationSource thread-safe and can it be used in the way I described?

Here's how I use it:

private static IConfigurationSource source = new FileConfigurationSource("Validation.config");

// This method can be called simultaneously from different threads.
public static ValidationResults ValidateEntity(object entity, string ruleSet)
    // is the use of static field 'source' safe here?
    Validator validator = ValidationFactory.CreateValidator(entity.GetType(), ruleSet, source);
    return validator.Validate(entity);

Mar 20, 2009 at 3:01 PM
Edited Mar 20, 2009 at 3:01 PM
duplicate post. Answered here :