Inheritance: ConfigurationValidatorBase
コード例 #1
0
		public void CanValidate ()
		{
			DefaultValidator v = new DefaultValidator ();

			Assert.IsTrue (v.CanValidate (typeof (string)));
			Assert.IsTrue (v.CanValidate (typeof (int)));
			Assert.IsTrue (v.CanValidate (typeof (object)));
		}
コード例 #2
0
		public void Validate ()
		{
			DefaultValidator v = new DefaultValidator ();

			v.Validate (5);
			v.Validate (5.4);
			v.Validate ("hi there");
			v.Validate (v);
		}
コード例 #3
0
 private static ConfigurationValidatorBase GetValidator(MemberInfo mi)
 {
     ConfigurationValidatorBase validator = new DefaultValidator();
     var validators = mi.GetAttributes<ValidationAttribute>();
     if (validators.IsNullOrEmpty() == false)
     {
         validator = new CompositeConfigurationValidator(validators, mi.Name);
     }
     return validator;
 }