本文整理汇总了C#中ValidatorEngine类的典型用法代码示例。如果您正苦于以下问题:C# ValidatorEngine类的具体用法?C# ValidatorEngine怎么用?C# ValidatorEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValidatorEngine类属于命名空间,在下文中一共展示了ValidatorEngine类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: NHibernateValidatorClientModelValidator
public NHibernateValidatorClientModelValidator(ModelMetadata metadata, ControllerContext controllerContext, IClassValidator validator, ValidatorEngine engine)
: base(metadata, controllerContext)
{
_engine = engine;
_validator = validator;
this.PropertyName = metadata.PropertyName;
}
开发者ID:sztupy,项目名称:shaml,代码行数:7,代码来源:NHibernateValidatorClientModelValidator.cs
示例2: InterpolatingMemberAndSubMembers
public void InterpolatingMemberAndSubMembers()
{
var c = new Contractor
{
SubcontractorHourEntries = new List<SubcontractorHourEntry>
{
new SubcontractorHourEntry
{
Contrator = new SubContractor(1),
Hour = 9
},
new SubcontractorHourEntry
{
Contrator = new SubContractor(2),
Hour = 10
}
}
};
var vtor = new ValidatorEngine();
Assert.IsFalse(vtor.IsValid(c));
var values = vtor.Validate(c);
Assert.AreEqual(1, values.Length);
Assert.AreEqual("The min value in the SubContractor Id: 1 is invalid. Instead was found: 9", values[0].Message);
}
开发者ID:spib,项目名称:nhcontrib,代码行数:25,代码来源:InterpolatingValuesFixture.cs
示例3: GetValidatorEngine
private static ValidatorEngine GetValidatorEngine()
{
var cfg = GetNhvConfiguration();
var validatorEngine = new ValidatorEngine();
validatorEngine.Configure(cfg);
return validatorEngine;
}
开发者ID:akhuang,项目名称:NHibernate,代码行数:7,代码来源:Program.cs
示例4: ManuallyBuildValidatorSources
private static IValidatorEngine ManuallyBuildValidatorSources()
{
var scanSource = new ModelScanValidatorSource();
var customerValidatorSource = new CustomerValidatorSource();
var engine = new ValidatorEngine(new IValidatorSource[] { scanSource, customerValidatorSource });
return engine;
}
开发者ID:jeffdoolittle,项目名称:expressval,代码行数:7,代码来源:Program.cs
示例5: 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);
}
开发者ID:Ivanidze,项目名称:IvanidzeSimpleStore,代码行数:29,代码来源:NHVConfigurator.cs
示例6: 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;
}
开发者ID:josephv,项目名称:Hilvilla,代码行数:11,代码来源:Validation.cs
示例7: 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'"));
}
开发者ID:spib,项目名称:nhcontrib,代码行数:30,代码来源:StringConstraintsTests.cs
示例8: IntegrationWithValidation
public void IntegrationWithValidation()
{
ValidatorEngine ve = new ValidatorEngine();
ve.AssertValid(new Foo(1));
Assert.IsFalse(ve.IsValid(new Foo(3)));
}
开发者ID:pruiz,项目名称:nhibernate-contrib-old,代码行数:7,代码来源:ValidatorClassFixture.cs
示例9: ConfigureNHibernate
/// <summary>
/// Metodo responsavel por executar o mapeamento das classes com o banco de dados
/// </summary>
/// <param name="databaseConfigurer"></param>
/// <param name="validatorEngine"></param>
/// <returns></returns>
private static ISessionFactory ConfigureNHibernate(IPersistenceConfigurer databaseConfigurer,
out ValidatorEngine validatorEngine)
{
ValidatorEngine ve = null;
ISessionFactory factory = Fluently.Configure()
.Database(databaseConfigurer)
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<UsuarioMap>()
.Conventions.Add(typeof(CascadeAll))
)
.Cache(x =>
x.UseQueryCache()
.UseSecondLevelCache()
.ProviderClass<SysCacheProvider>()
)
.ExposeConfiguration(c =>
{
ve = ConfigureValidator(c);
c.SetProperty("adonet.batch_size", "5");
c.SetProperty("generate_statistics", "false");
//c.SetProperty("cache.use_second_level_cache", "true");
})
.BuildConfiguration().BuildSessionFactory();
validatorEngine = ve;
return factory;
}
开发者ID:rafaelo4n,项目名称:Progas.Portal,代码行数:34,代码来源:SessionManager.cs
示例10: NoEndlessLoop
public void NoEndlessLoop()
{
var john = new User("John", null);
john.Knows(john);
var validator = new ValidatorEngine();
InvalidValue[] constraintViolations = validator.Validate(john);
Assert.AreEqual(constraintViolations.Length, 1, "Wrong number of constraints");
Assert.AreEqual("LastName", constraintViolations.ElementAt(0).PropertyName);
var jane = new User("Jane", "Doe");
jane.Knows(john);
john.Knows(jane);
constraintViolations = validator.Validate(john);
Assert.AreEqual(constraintViolations.Length, 1, "Wrong number of constraints");
Assert.AreEqual("LastName", constraintViolations.ElementAt(0).PropertyName);
constraintViolations = validator.Validate(jane);
Assert.AreEqual(1, constraintViolations.Length, "Wrong number of constraints");
Assert.AreEqual(constraintViolations.ElementAt(0).PropertyPath, "knowsUser[0].LastName");
john.LastName = "Doe";
constraintViolations = validator.Validate(john);
Assert.AreEqual(0, constraintViolations.Length, "Wrong number of constraints");
}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:27,代码来源:Fixture.cs
示例11: ConfigureFile
public void ConfigureFile()
{
// This test is for .Configure(XmlReader) too
string tmpf = Path.GetTempFileName();
using (StreamWriter sw = new StreamWriter(tmpf))
{
sw.WriteLine("<?xml version='1.0' encoding='utf-8' ?>");
sw.WriteLine("<nhv-configuration xmlns='urn:nhv-configuration-1.0'>");
sw.WriteLine("<property name='apply_to_ddl'>false</property>");
sw.WriteLine("<property name='autoregister_listeners'>false</property>");
sw.WriteLine("<property name='default_validator_mode'>OverrideAttributeWithExternal</property>");
sw.WriteLine("<property name='message_interpolator_class'>"
+ typeof(PrefixMessageInterpolator).AssemblyQualifiedName + "</property>");
sw.WriteLine("</nhv-configuration>");
sw.Flush();
}
ValidatorEngine ve = new ValidatorEngine();
ve.Configure(tmpf);
Assert.AreEqual(false, ve.ApplyToDDL);
Assert.AreEqual(false, ve.AutoRegisterListeners);
Assert.AreEqual(ValidatorMode.OverrideAttributeWithExternal, ve.DefaultMode);
Assert.IsNotNull(ve.Interpolator);
Assert.AreEqual(typeof(PrefixMessageInterpolator), ve.Interpolator.GetType());
}
开发者ID:mpielikis,项目名称:nhibernate-contrib,代码行数:26,代码来源:ValidatorEngineFixture.cs
示例12: 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);
}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:8,代码来源:ValidatorEngineTaggingXml.cs
示例13: 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);
}
开发者ID:spib,项目名称:nhcontrib,代码行数:8,代码来源:ValidComponentTester.cs
示例14: 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);
}
开发者ID:Linkgoron,项目名称:Second-Basic-Demo,代码行数:9,代码来源:DbConfiguration.cs
示例15: ViewValidator
public ViewValidator(ValidatorEngine validatorEngine, ErrorProvider errorProvider)
: this(errorProvider)
{
Check.NotNull(
validatorEngine,
"ve",
"The ValidatorEngine is null");
this.validatorEngine = validatorEngine;
}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:9,代码来源:ViewValidator.cs
示例16: CreateValidatorEngine
public void CreateValidatorEngine()
{
var configure = new FluentConfiguration();
configure.Register(new[] {typeof (UserValidation), typeof (GroupValidation)})
.SetDefaultValidatorMode(ValidatorMode.UseExternal);
validatorEngine = new ValidatorEngine();
validatorEngine.Configure(configure);
}
开发者ID:spib,项目名称:nhcontrib,代码行数:9,代码来源:Fixture.cs
示例17: 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;
}
开发者ID:spib,项目名称:nhcontrib,代码行数:10,代码来源:Fixture.cs
示例18: 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);
}
开发者ID:spib,项目名称:nhcontrib,代码行数:10,代码来源:ValidComponentTester.cs
示例19: 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 }));
}
开发者ID:spib,项目名称:nhcontrib,代码行数:10,代码来源:EngineIntegrationTest.cs
示例20: 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;
}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:10,代码来源:DdlForComponents.cs
注:本文中的ValidatorEngine类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论