1

I am stepping into the world of validation attributes in an attempt to subscribe more strongly to DRY. I do not use the in-the-box resource system because by experience it is buggy as hell. So I've developed an XML based resource provider that is so much better, but I find I can't use it with the System.ComponentModel.DataAnnotations.ValidationAttribute family of classes. It seems like a huge restriction to require a resource type to have hard-coded static properties for its resources. I would have thought an interface would have been more reasonable. Is there a way i can hack this using reflection or something so that the resourcing system for these attributes think that they are reading from a static property but are actually going though my component's method?

This is the interface for my resource provider.

public interface IStringProvider
{
    String GetValue(String a_name, params Object[] a_params);
}

For now, I guess I have to create static property "stand-ins" which is a lot of extra code, I'd like to avoid.

Thanks always.

Jordan
  • 9,642
  • 10
  • 71
  • 141
  • I really don't know what you found buggy about the standard resource system. Its been around for a decade at least, and never posed any problems in my experience (used it extensively including localization). I know, this not answering your question, I am just questioning the generic "buggy as hell" statement. Thanks – Display Name Mar 13 '13 at 17:33
  • I've only used it in combination with XAML (i.e. WPF and Silverlight) and it would create ridiculous exceptions that didn't make sense and with which no one could help me. It's been a while, but it left a really bad taste in my mouth. I've since rolled my own XML based solution though that works wonderfully. – Jordan Mar 13 '13 at 17:52

0 Answers0