当前位置: 首页>>代码示例>>C#>>正文


C# ValidatorEngine.Configure方法代码示例

本文整理汇总了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;
 }
开发者ID:akhuang,项目名称:NHibernate,代码行数:7,代码来源:Program.cs

示例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);
        }
开发者ID:Ivanidze,项目名称:IvanidzeSimpleStore,代码行数:29,代码来源:NHVConfigurator.cs

示例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;
        }
开发者ID:josephv,项目名称:Hilvilla,代码行数:11,代码来源:Validation.cs

示例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'"));
        }
开发者ID:spib,项目名称:nhcontrib,代码行数:30,代码来源:StringConstraintsTests.cs

示例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);
 }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:8,代码来源:ValidatorEngineTaggingXml.cs

示例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);
        }
开发者ID:spib,项目名称:nhcontrib,代码行数:8,代码来源:ValidComponentTester.cs

示例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);
        }
开发者ID:spib,项目名称:nhcontrib,代码行数:9,代码来源:Fixture.cs

示例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);
        }
开发者ID:Linkgoron,项目名称:Second-Basic-Demo,代码行数:9,代码来源:DbConfiguration.cs

示例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;
 }
开发者ID:spib,项目名称:nhcontrib,代码行数:10,代码来源:Fixture.cs

示例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 }));
        }
开发者ID:spib,项目名称:nhcontrib,代码行数:10,代码来源:EngineIntegrationTest.cs

示例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;
 }
开发者ID:spib,项目名称:nhcontrib,代码行数:10,代码来源:ConstraintFactoryFixture.cs

示例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;
 }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:10,代码来源:DdlForComponents.cs

示例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);
 }
开发者ID:spib,项目名称:nhcontrib,代码行数:10,代码来源:ValidComponentTester.cs

示例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());
        }
开发者ID:mpielikis,项目名称:nhibernate-contrib,代码行数:11,代码来源:ValidatorEngineFixture.cs

示例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();
        }
开发者ID:spib,项目名称:nhcontrib,代码行数:11,代码来源:EngineIntegrationTest.cs


注:本文中的ValidatorEngine.Configure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。