本文整理汇总了C#中ValidatorEngine.GetValidator方法的典型用法代码示例。如果您正苦于以下问题:C# ValidatorEngine.GetValidator方法的具体用法?C# ValidatorEngine.GetValidator怎么用?C# ValidatorEngine.GetValidator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ValidatorEngine
的用法示例。
在下文中一共展示了ValidatorEngine.GetValidator方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanInitialezeValidatorEngine
public void CanInitialezeValidatorEngine()
{
var fc = new FluentConfiguration();
fc.SetDefaultValidatorMode(ValidatorMode.UseExternal)
.Register<AddressValidationDef, Address>().Register<BooValidationDef, Boo>()
.IntegrateWithNHibernate.AvoidingDDLConstraints().And.AvoidingListenersRegister();
var ve = new ValidatorEngine();
ve.Configure(fc);
Assert.That(ve.GetValidator<Address>(), Is.Not.Null);
Assert.That(ve.GetValidator<Boo>(), Is.Not.Null);
}
示例2: GetMemberConstraintsLoquacious
public void GetMemberConstraintsLoquacious()
{
var configure = new FluentConfiguration();
configure.Register(
Assembly.GetExecutingAssembly().ValidationDefinitions().Where(x=>x.Equals(typeof(AddressDef))))
.SetDefaultValidatorMode(ValidatorMode.UseExternal);
var ve = new ValidatorEngine();
ve.Configure(configure);
IClassValidator cv = ve.GetValidator<Address>();
IEnumerable<Attribute> ma = cv.GetMemberConstraints("Country");
Assert.That(ma.Count(), Is.EqualTo(2));
Assert.That(ma.Count(x => x.TypeId == (new NotNullAttribute()).TypeId), Is.EqualTo(1));
Assert.That(ma.Count(x => x.TypeId == (new LengthAttribute()).TypeId), Is.EqualTo(1));
}
示例3: ValidateAnyClass
public void ValidateAnyClass()
{
ValidatorEngine ve = new ValidatorEngine();
Assert.IsTrue(ve.IsValid(new AnyClass()));
Assert.IsNotNull(ve.GetValidator<AnyClass>());
ve.AssertValid(new AnyClass()); // not cause exception
Assert.AreEqual(0, ve.Validate(new AnyClass()).Length);
Assert.AreEqual(0, ve.ValidatePropertyValue<AnyClass>("aprop", new AnyClass()).Length);
Assert.AreEqual(0, ve.ValidatePropertyValue(new AnyClass(), "aprop").Length);
Assert.AreEqual(0, ve.Validate("always valid").Length);
Assert.AreEqual(0, ve.ValidatePropertyValue("always valid", "Length").Length);
}
示例4: AddValidatorWithoutUseIt
public void AddValidatorWithoutUseIt()
{
ValidatorEngine ve = new ValidatorEngine();
ve.AddValidator<Boo>();
Assert.IsNotNull(ve.GetValidator<Boo>());
}
示例5: InitializeValidators
public void InitializeValidators()
{
ValidatorEngine ve = new ValidatorEngine();
XmlConfiguration nhvc = new XmlConfiguration();
nhvc.Properties[Environment.ApplyToDDL] = "false";
nhvc.Properties[Environment.AutoregisterListeners] = "false";
nhvc.Properties[Environment.ValidatorMode] = "overrideattributewithExternal";
nhvc.Properties[Environment.MessageInterpolatorClass] = typeof(PrefixMessageInterpolator).AssemblyQualifiedName;
string an = Assembly.GetExecutingAssembly().FullName;
nhvc.Mappings.Add(new MappingConfiguration(an, "NHibernate.Validator.Tests.Base.Address.nhv.xml"));
ve.Configure(nhvc);
Assert.IsNotNull(ve.GetValidator<Address>());
Assert.IsNull(ve.GetValidator<Boo>());
// Validate something and then its validator is initialized
Boo b = new Boo();
ve.IsValid(b);
Assert.IsNotNull(ve.GetValidator<Boo>());
}