예제 #1
0
파일: Form1.cs 프로젝트: hackerlank/ygrinev
        private void button1_Click_1(object sender, EventArgs e)
        {
            List <ValidationResult> errors = new List <ValidationResult>();

            foreach (TabPage p in tabControl1.TabPages)
            {
                IValidateable obj = (IValidateable)Activator.CreateInstance(Type.GetType("DataAnnotation1." + p.Name.Substring(3)));
                obj.Init(p);
                //VALIDATION!!
                Validator.ParseNValidate(obj, errors);
            }
            MessageBox.Show(errors.Count < 1 ? "SUCCESS!!" : string.Join("", errors.Select(er => er.ErrorMessage).ToArray()));
        }