Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
 public void OnError(Exception error)
 {
     MessageBoxExtension.ShowError(error.Message);
 }