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


C# ValidatorEngine.GetValidator方法代码示例

本文整理汇总了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);
        }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:12,代码来源:FluentConfigurationFixture.cs

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

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

示例4: AddValidatorWithoutUseIt

 public void AddValidatorWithoutUseIt()
 {
     ValidatorEngine ve = new ValidatorEngine();
     ve.AddValidator<Boo>();
     Assert.IsNotNull(ve.GetValidator<Boo>());
 }
开发者ID:mpielikis,项目名称:nhibernate-contrib,代码行数:6,代码来源:ValidatorEngineFixture.cs

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


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