本文整理汇总了C#中ValidatorEngine.Configure方法的典型用法代码示例。如果您正苦于以下问题:C# ValidatorEngine.Configure方法的具体用法?C# ValidatorEngine.Configure怎么用?C# ValidatorEngine.Configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ValidatorEngine
的用法示例。
在下文中一共展示了ValidatorEngine.Configure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetValidatorEngine
private static ValidatorEngine GetValidatorEngine()
{
var cfg = GetNhvConfiguration();
var validatorEngine = new ValidatorEngine();
validatorEngine.Configure(cfg);
return validatorEngine;
}
示例2: Configure
public void Configure(IWindsorContainer container)
{
var ve = new ValidatorEngine();
container.Register(Component.For<IEntityValidator>()
.ImplementedBy<EntityValidator>());
container.Register(Component.For<ValidatorEngine>()
.Instance(ve)
.LifeStyle.Singleton);
//Register the service for ISharedEngineProvider
container.Register(Component.For<ISharedEngineProvider>()
.ImplementedBy<NHVSharedEngineProvider>());
//Assign the shared engine provider for NHV.
Environment.SharedEngineProvider =
container.Resolve<ISharedEngineProvider>();
//Configure validation framework fluently
var configure = new FluentConfiguration();
configure.Register(typeof (WorkerValidationDefenition).Assembly.ValidationDefinitions())
.SetDefaultValidatorMode(ValidatorMode.OverrideAttributeWithExternal)
.AddEntityTypeInspector<NHVTypeInspector>()
.IntegrateWithNHibernate.ApplyingDDLConstraints().And.RegisteringListeners();
ve.Configure(configure);
}
示例3: CreateValidationEngine
///<remarks>
/// The output of this function should be either put into your IoC container or cached somewhere to prevent
/// re-reading of the config files.
///</remarks>
public static ValidatorEngine CreateValidationEngine()
{
var validator = new ValidatorEngine();
validator.Configure();
return validator;
}
示例4: ValidateWithMultipleConditions
public void ValidateWithMultipleConditions()
{
var configure = new FluentConfiguration();
var validationDef = new ValidationDef<EntityWithString>();
validationDef.Define(e => e.Name)
.Satisfy(name => name != null && name.StartsWith("ab")).WithMessage("Name should start with 'ab'")
.And
.Satisfy(name => name != null && name.EndsWith("zz")).WithMessage("Name should end with 'zz'");
configure.Register(validationDef).SetDefaultValidatorMode(ValidatorMode.UseExternal);
var ve = new ValidatorEngine();
ve.Configure(configure);
Assert.That(ve.IsValid(new EntityWithString { Name = "abczz" }));
Assert.That(!ve.IsValid(new EntityWithString { Name = "bc" }));
var iv = ve.Validate(new EntityWithString {Name = "abc"});
Assert.That(iv.Length, Is.EqualTo(1));
Assert.That(iv.Select(i => i.Message).First(), Is.EqualTo("Name should end with 'zz'"));
iv = ve.Validate(new EntityWithString { Name = "zz" });
Assert.That(iv.Length, Is.EqualTo(1));
Assert.That(iv.Select(i => i.Message).First(), Is.EqualTo("Name should start with 'ab'"));
iv = ve.Validate(new EntityWithString { Name = "bc" });
Assert.That(iv.Length, Is.EqualTo(2));
var messages = iv.Select(i => i.Message);
Assert.That(messages, Has.Member("Name should start with 'ab'") & Has.Member("Name should end with 'zz'"));
}
示例5: CreateEngine
public void CreateEngine()
{
var conf = new XmlConfiguration();
conf.Properties[Environment.ValidatorMode] = "UseExternal";
conf.Mappings.Add(new MappingConfiguration("NHibernate.Validator.Tests", "NHibernate.Validator.Tests.Engine.Tagging.EntityXml.nhv.xml"));
ve = new ValidatorEngine();
ve.Configure(conf);
}
示例6: when_validate_customer_with_invalid_name_and_email_should_return_two_invalid_values
public void when_validate_customer_with_invalid_name_and_email_should_return_two_invalid_values()
{
var validatorEngine = new ValidatorEngine();
var notValidCustomer = GetNotValidCustomer();
validatorEngine.Configure();
validatorEngine.Validate(notValidCustomer).Should().Have.Count.EqualTo(2);
}
示例7: CreateValidatorEngine
public void CreateValidatorEngine()
{
var configure = new FluentConfiguration();
configure.Register(new[] {typeof (UserValidation), typeof (GroupValidation)})
.SetDefaultValidatorMode(ValidatorMode.UseExternal);
validatorEngine = new ValidatorEngine();
validatorEngine.Configure(configure);
}
示例8: ConfigureNHibernateValidator
private static void ConfigureNHibernateValidator(Configuration configuration)
{
INHVConfiguration nhvc = (INHVConfiguration)new NHibernate.Validator.Cfg.Loquacious.FluentConfiguration()
.SetDefaultValidatorMode(ValidatorMode.UseAttribute);
var validator = new ValidatorEngine();
validator.Configure(nhvc);
configuration.Initialize(validator);
}
示例9: GetValidatorEngine
public ValidatorEngine GetValidatorEngine()
{
var vtor = new ValidatorEngine();
var cfg = new XmlConfiguration();
cfg.Properties[Environment.ValidatorMode] = "UseExternal";
string an = Assembly.GetExecutingAssembly().FullName;
cfg.Mappings.Add(new MappingConfiguration(an, "NHibernate.Validator.Tests.Specifics.NHV29.Mappings.nhv.xml"));
vtor.Configure(cfg);
return vtor;
}
示例10: DelegatedValidate_WithoutMessageNotThrow
public void DelegatedValidate_WithoutMessageNotThrow()
{
var configure = new FluentConfiguration();
configure.Register(new[] { typeof(RangeDefWithoutCustomMessage) })
.SetDefaultValidatorMode(ValidatorMode.UseExternal);
var ve = new ValidatorEngine();
ve.Configure(configure);
ActionAssert.NotThrow(()=>ve.IsValid(new Range { Start = 1, End = 4 }));
}
示例11: GetValidatorEngine
public virtual ValidatorEngine GetValidatorEngine()
{
var ve = new ValidatorEngine();
var cfg = new XmlConfiguration();
cfg.Properties[Environment.ValidatorMode] = "UseAttribute";
cfg.Properties[Environment.ConstraintValidatorFactoryClass] =
typeof (TestConstraintValidatorFactory).AssemblyQualifiedName;
ve.Configure(cfg);
return ve;
}
示例12: ConfigureValidator
protected ValidatorEngine ConfigureValidator(NHibernate.Cfg.Configuration configuration)
{
var nhvc = new FluentConfiguration();
nhvc.SetDefaultValidatorMode(ValidatorMode.UseExternal).IntegrateWithNHibernate.ApplyingDDLConstraints();
nhvc.Register<PersonValidation, Person>();
nhvc.Register<NameValidation, Name>();
var engine = new ValidatorEngine();
engine.Configure(nhvc);
return engine;
}
示例13: Configure
protected override void Configure(NHibernate.Cfg.Configuration configuration)
{
base.Configure(configuration);
var nhvc = new FluentConfiguration();
nhvc.SetDefaultValidatorMode(ValidatorMode.UseAttribute).IntegrateWithNHibernate.ApplyingDDLConstraints().And.
RegisteringListeners();
var onlyToUseToInitializeNh_Engine = new ValidatorEngine();
onlyToUseToInitializeNh_Engine.Configure(nhvc);
configuration.Initialize(onlyToUseToInitializeNh_Engine);
}
示例14: Configure
public void Configure()
{
ValidatorEngine ve = new ValidatorEngine();
ve.Configure();
Assert.AreEqual(true, ve.ApplyToDDL);
Assert.AreEqual(true, ve.AutoRegisterListeners);
Assert.AreEqual(ValidatorMode.UseAttribute, ve.DefaultMode);
Assert.IsNotNull(ve.Interpolator);
Assert.AreEqual(typeof(PrefixMessageInterpolator), ve.Interpolator.GetType());
}
示例15: DelegatedValidate_WithoutMessageHasInvalidValue
public void DelegatedValidate_WithoutMessageHasInvalidValue()
{
var configure = new FluentConfiguration();
configure.Register(new[] { typeof(RangeDefWithoutCustomMessage) })
.SetDefaultValidatorMode(ValidatorMode.UseExternal);
var ve = new ValidatorEngine();
ve.Configure(configure);
var iv = ve.Validate(new Range {Start = 5, End = 4});
iv.Should().Not.Be.Empty();
}