public static void IntegerValidatorInstance()
        {
            //<Snippet13>

            ConfigurationValidatorBase valBase;
            IntegerValidatorAttribute  intValAttr;

            intValAttr = new IntegerValidatorAttribute();

            long badValue  = 10;
            int  goodValue = 10;

            try
            {
                valBase = intValAttr.ValidatorInstance;
                valBase.Validate(goodValue);
                // valBase.Validate(badValue);
            }
            catch (ArgumentException e)
            {
                // Display error message.
                string msg = e.ToString();
#if DEBUG
                Console.WriteLine(msg);
#endif
            }
            //</Snippet13>
        }
        public void IntegerValidatorAttribute_Ctor()
        {
            IntegerValidatorAttribute attrib = new IntegerValidatorAttribute();

            Assert.Equal(Int32.MinValue, attrib.MinValue);
            Assert.Equal(Int32.MaxValue, attrib.MaxValue);
            Assert.IsType <IntegerValidator>(attrib.Validator);
        }
Ejemplo n.º 3
0
        private void widthUpDown_Validating(object sender, CancelEventArgs e)
        {
            ConfigurationValidatorBase validatorBase;
            IntegerValidatorAttribute  intValAttr;

            intValAttr = new IntegerValidatorAttribute();


            int goodValue = 24;

            try
            {
                validatorBase = intValAttr.ValidatorInstance;
                validatorBase.Validate(goodValue);
            }
            catch (ArgumentException)
            {
                string msg = e.ToString();
#if DEBUG
                Console.WriteLine(msg);
#endif
            }
        }