33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using GeneralApi.Core.Infrastructure.Validation;
|
|
using NHibernate.Validator.Cfg;
|
|
using NHibernate.Validator.Cfg.Loquacious;
|
|
using NHibernate.Validator.Engine;
|
|
|
|
namespace GeneralApi.Core.Infrastructure.DataAccess
|
|
{
|
|
public class NHValidatorConfiguration
|
|
{
|
|
public static ValidatorEngine Configure()
|
|
{
|
|
var ve = new ValidatorEngine();
|
|
|
|
var nhvc = new FluentConfiguration();
|
|
var validationDefinitions = Assembly.GetExecutingAssembly().GetTypes()
|
|
.Where(t => t.Namespace == typeof (CondoValidationDef).Namespace)
|
|
.ValidationDefinitions();
|
|
nhvc.Register(validationDefinitions)
|
|
.SetDefaultValidatorMode(ValidatorMode.UseExternal);
|
|
// nhvc.Properties[Environment.ApplyToDDL] = "false";
|
|
// nhvc.Properties[Environment.AutoregisterListeners] = "false";
|
|
// nhvc.Properties[Environment.ValidatorMode] = GetMode();
|
|
// nhvc.Mappings.Add(new MappingConfiguration("NHibernate.Validator.Demo.Model", null));
|
|
ve.Configure(nhvc);
|
|
return ve;
|
|
}
|
|
}
|
|
}
|