I have a feeling this may be stupid question, but I can’t come to the simple solution that I’m sure exists.
I have a C# class that validates a configuration file against some other file.
There may be two kinds of errors, which are represented in an enum:
public enum ErrorType
{
VersionsMismatch,
UnsupportedCombination
}
There is a struct representing the error:
public struct ValiditionResult
{
public bool Valid { get; set; }
public string ErrorMessage { get; set; }
public ErrorType ErrorType { get; set; }
public List<ConfProperties> InvalidProperties {get;set;}
}
The function interface look like this:
public ValiditionResult Validate(string confFile, string progFile)
The struct represents the fixes required in the files.
So if there are two types of fixes, it should be specified.
What is the best way to indicate all the errors occured (there may be more than two in the future)?
To return a list of the ValidationResult struct? to make some XOR of the Enum? Any other idea?
You could mark your enum with the attribute [Flags]
see http://msdn.microsoft.com/en-us/library/system.flagsattribute.aspx for more info.