public static int Parse(this string input, int oldValue) { int newValue; var parsed = int.TryParse(input, out newValue); if (!parsed) { MessageBoxExtension.ShowWarning(onlyIntegerMessage); return(oldValue); } return(newValue); }
private static T ParseAndValidate <T>(bool parsed, T newValue, T oldValue, IValidator <T> validator, string parseFailedMessage) { if (!parsed) { MessageBoxExtension.ShowWarning(parseFailedMessage); return(oldValue); } if (!validator.IsValid(newValue)) { MessageBoxExtension.ShowWarning(validator.GetInvalidInfoMessage()); return(oldValue); } return(newValue); }