I've a c# application(in fact it runs into a windows service or like a windows application).
In receive the configuration for one run of the service/application from an XML file.
This XML file is in fact only my data serialized/deserialized in XML. It's one of my other application that generate it.
Before running the business code, I would like to ensure that the configuration file is valid.
By this I mean things like "This String must not be null", "This TimeSpan must have a value greater than XYZ", ...
So only verification that can be made by seing the content of the field(no need to access to something else).
It reminds me a lot the Data Annotation that I used in asp.Net MVC, and I would like if there is something similar for simple c# code, without having to load the whole asp.net MVC dll.
My other option is to implement a method "Validate()" which throw an exception if one field is incorrect, but I will have a lot of if(String.IsNullOrEmpty()
and other dummy validations.
I do not want to implement myself a big validator that uses reflexion, it's a bit overkill for only a small configuration file verification.
The application which generate those file could also be interessted to use those same validation.
Edit: I've to use .Net 3.5