private static IMigrationRunner CreateRunner() { var settings = new NHibernateSettings(); var configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: false) .AddEnvironmentVariables() .Build(); configuration.Bind("Postgres", settings); var scope = new ServiceCollection() .AddFluentMigratorCore() .ConfigureRunner(runner => runner .AddPostgres() .WithGlobalConnectionString(settings.ConnectionString) .ScanIn(typeof(Program).Assembly).For.Migrations()) .AddLogging(logging => logging.Services .AddSingleton <ILoggerProvider, FluentMigratorConsoleLoggerProvider>() .Configure <FluentMigratorLoggerOptions>(options => { options.ShowSql = true; options.ShowElapsedTime = true; })) .BuildServiceProvider() .CreateScope(); return(scope.ServiceProvider.GetRequiredService <IMigrationRunner>()); }
public static ISessionFactory CreateSessionFactory(NHibernateSettings settings) { var configuration = new Configuration().SetNamingStrategy(new PostgresNamingStrategy()); return(Fluently.Configure(configuration) .Database(PostgreSQLConfiguration.PostgreSQL82.ConnectionString(settings.ConnectionString)) .Mappings(ConfigureMappings) .BuildSessionFactory()); }
public NHibernateAuthorization(AdapterSettings settings, IDictionary keyRing, NHibernateSettings nhSettings) : base(settings, keyRing) { _authorizationPath = string.Format("{0}Authorization.{1}.xml", _settings["AppDataPath"], _settings["Scope"] ); _nhSettings = nhSettings; }
public NHibernateDataLayer(AdapterSettings settings, IDictionary keyRing) : base(settings) { var ninjectSettings = new NinjectSettings { LoadExtensions = false, UseReflectionBasedInjection = true }; _kernel = new StandardKernel(ninjectSettings, new NHibernateModule()); _kernel.Load(new XmlExtensionModule()); _nSettings = _kernel.Get <NHibernateSettings>(); _nSettings.AppendSettings(settings); _keyRing = keyRing; _kernel.Rebind <AdapterSettings>().ToConstant(_settings); _kernel.Bind <IDictionary>().ToConstant(_keyRing).Named("KeyRing"); _dataDictionaryPath = string.Format("{0}DataDictionary.{1}.xml", _settings["AppDataPath"], _settings["Scope"] ); _dbDictionaryPath = string.Format("{0}DatabaseDictionary.{1}.xml", _settings["AppDataPath"], _settings["Scope"] ); string keyFile = string.Format("{0}{1}.{2}.key", _settings["AppDataPath"], _settings["ProjectName"], _settings["ApplicationName"]); if (File.Exists(_dbDictionaryPath)) { _dbDictionary = NHibernateUtility.LoadDatabaseDictionary(_dbDictionaryPath, keyFile); } else if (utility.Utility.isLdapConfigured && utility.Utility.FileExistInRepository <DatabaseDictionary>(_dbDictionaryPath)) { _dbDictionary = NHibernateUtility.LoadDatabaseDictionary(_dbDictionaryPath, keyFile); } _dataDictionary = new DataDictionary(); _dataDictionary.dataObjects = _dbDictionary.dataObjects; string relativePath = String.Format("{0}AuthorizationBindingConfiguration.{1}.xml", _settings["AppDataPath"], _settings["Scope"] ); _authorizationBindingPath = Path.Combine( _settings["BaseDirectoryPath"], relativePath ); relativePath = String.Format("{0}SummaryBindingConfiguration.{1}.xml", _settings["AppDataPath"], _settings["Scope"] ); _summaryBindingPath = Path.Combine( _settings["BaseDirectoryPath"], relativePath ); //_kernel.Load(_authorizationBindingPath); if (File.Exists(_authorizationBindingPath)) { _kernel.Load(_authorizationBindingPath); } else if (utility.Utility.isLdapConfigured && utility.Utility.FileExistInRepository <XElementClone>(_authorizationBindingPath)) { XElement bindingConfig = Utility.GetxElementObject(_authorizationBindingPath); string fileName = Path.GetFileName(_authorizationBindingPath); string tempPath = Path.GetTempPath() + fileName; bindingConfig.Save(tempPath); _kernel.Load(tempPath); } else { _logger.Error("Authourization Binding configuration not found."); } }
public NHibernateSummary(AdapterSettings settings, IDictionary keyRing, NHibernateSettings nhSettings) : base(settings, keyRing) { _nhSettings = nhSettings; }