Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save wellingtonjhn/51d566ae7de2790e7a37787298fa498a to your computer and use it in GitHub Desktop.

Select an option

Save wellingtonjhn/51d566ae7de2790e7a37787298fa498a to your computer and use it in GitHub Desktop.
MySettings implementation with Validation using Data Annotations
public abstract class ConfigurationSettings
{
public List<ValidationResult> ValidationResult = new List<ValidationResult>();
public bool Validate() => Validator.TryValidateObject(
this,
new ValidationContext(this),
ValidationResult,
true);
}
public class MySettings : ConfigurationSettings
{
[Required]
public string ApplicationName { get; set; }
public string Author { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment