Exemplo n.º 1
0
        public PrimesBigInteger ValidateInput(TextBox tbSource)
        {
            PrimesBigInteger result = PrimesBigInteger.Zero;
            InputValidator <PrimesBigInteger> m_Validator;

            if (m_Validators.ContainsKey(tbSource.Tag.ToString()))
            {
                m_Validator = m_Validators[tbSource.Tag.ToString()];
            }
            else
            {
                m_Validator           = new InputValidator <PrimesBigInteger>();
                m_Validator.Validator = new BigIntegerValidator(tbSource.Text);
            }

            try
            {
                TextBoxValidator <PrimesBigInteger> tbvalidator = new TextBoxValidator <PrimesBigInteger>(m_Validator.Validator, tbSource, m_Validator.DefaultValue);
                tbvalidator.Validate(ref result);
            }
            catch (ControlValidationException cvex)
            {
                cvex.HelpAction = m_Validator.LinkOnlinehelp;
                throw cvex;
            }

            return(result);
        }
Exemplo n.º 2
0
        private PrimesBigInteger GetPrimesCount()
        {
            PrimesBigInteger result = PrimesBigInteger.One;

            try
            {
                IValidator <PrimesBigInteger>       validator   = new BigIntegerMinValueValidator(tbN.Text, PrimesBigInteger.ValueOf(1));
                TextBoxValidator <PrimesBigInteger> tbValidator = new TextBoxValidator <PrimesBigInteger>(validator, tbN, "1");
                tbValidator.Validate(ref result);
            }
            catch (ControlValidationException cvex)
            {
                switch (cvex.ValidationResult)
                {
                case Primes.WpfControls.Validation.ValidationResult.WARNING:
                    Info(cvex.Message, cvex.Control as TextBox);
                    break;

                case Primes.WpfControls.Validation.ValidationResult.ERROR:
                    Error(cvex.Message, cvex.Control as TextBox);
                    break;
                }
            }

            return(result);
        }