Created
August 30, 2018 06:15
-
-
Save wellingtonjhn/51d566ae7de2790e7a37787298fa498a to your computer and use it in GitHub Desktop.
MySettings implementation with Validation using Data Annotations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class ConfigurationSettings | |
| { | |
| public List<ValidationResult> ValidationResult = new List<ValidationResult>(); | |
| public bool Validate() => Validator.TryValidateObject( | |
| this, | |
| new ValidationContext(this), | |
| ValidationResult, | |
| true); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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