public void Initialise()
        {
            var provider = new NHibernateSharedEngineProvider();
            NHibernate.Validator.Cfg.Environment.SharedEngineProvider = provider;

            // Configure the xVal validation framework to accept validation rules from NHibernate.Validator
            xVal.ActiveRuleProviders.Providers.Add(new ValidatorRulesProvider());
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);

            var engineProvider = new NHibernateSharedEngineProvider();
            engineProvider.GetEngine().Configure();

            NHibernate.Validator.Cfg.Environment.SharedEngineProvider = engineProvider;
        }
        protected override void Configure(NHibernate.Cfg.Configuration configuration)
        {
            // The ValidatorInitializer and the ValidateEventListener share the same engine

            // Initialize the SharedEngine
            fortest = new NHibernateSharedEngineProvider();
            Environment.SharedEngineProvider = fortest;
            ValidatorEngine ve = Environment.SharedEngineProvider.GetEngine();
            ve.Clear();
            XmlConfiguration nhvc = new XmlConfiguration();
            nhvc.Properties[Environment.ApplyToDDL] = "true";
            nhvc.Properties[Environment.AutoregisterListeners] = "true";
            nhvc.Properties[Environment.ValidatorMode] = "useExternal";
            nhvc.Properties[Environment.MessageInterpolatorClass] = typeof(PrefixMessageInterpolator).AssemblyQualifiedName;
            ve.Configure(nhvc);
            ve.IsValid(new AnyClass());// add the element to engine for test

            ValidatorInitializer.Initialize(configuration);
        }
 public static void InicializeValidator(LanguageEnum languageValidation)
 {
     NHibernate.Validator.Cfg.Environment.LanguageValidation = languageValidation;
     var provider = new NHibernateSharedEngineProvider();
     NHibernate.Validator.Cfg.Environment.SharedEngineProvider = provider;
 }
Exemplo n.º 5
0
 private void InitializeValidator()
 {
     var provider = new NHibernateSharedEngineProvider();
     NHibernate.Validator.Cfg.Environment.SharedEngineProvider = provider;
 }
        private static void ConfigureNhibernate(Configuration config)
        {
            var provider = new NHibernateSharedEngineProvider();
            NHibernate.Validator.Cfg.Environment.SharedEngineProvider = provider;

            var nhvConfiguration = new NHibernate.Validator.Cfg.Loquacious.FluentConfiguration();

            nhvConfiguration
               .SetDefaultValidatorMode(ValidatorMode.OverrideExternalWithAttribute)
               .Register(Assembly.GetExecutingAssembly().ValidationDefinitions())
               .IntegrateWithNHibernate
                   .AvoidingDDLConstraints()
                   .RegisteringListeners();

            ValidatorEngine validatorEngine = NHibernate.Validator.Cfg.Environment.SharedEngineProvider.GetEngine();
            validatorEngine.Configure(nhvConfiguration);

            ValidatorInitializer.Initialize(config, validatorEngine);

            config.SetProperty("current_session_context_class", "thread_static");

            //fix bug: http://stackoverflow.com/questions/2361730/assertionfailure-null-identifier-fluentnh-sqlserverce
            config.SetProperty("connection.release_mode", "on_close");

            //// delete the existing db on each run
            //if (File.Exists(DbFile))
            //    File.Delete(DbFile);

            if (!File.Exists(HttpContext.Current.Server.MapPath(DbFile.Replace(@"|DataDirectory|", @"~/App_Data/"))))
            {
                SqlCEDbHelper.CreateDatabaseFile(DbFile);

                // this NHibernate tool takes a configuration (with mapping info in)
                // and exports a database schema from it
                new SchemaExport(config)
                    .Create(false, true);
            }
        }