private static InversionContainer build_items_for_container(ConfigurationPropertyHolder configuration_property_holder)
        {
            configuration_property_holder.DatabaseType = DatabaseTypeSynonyms.convert_database_type_synonyms(configuration_property_holder.DatabaseType);

            set_up_current_mappings(configuration_property_holder);

            Logger multiLogger = GetMultiLogger(configuration_property_holder);

            var container = new StructureMap.Container(cfg =>
            {
                cfg.For <ConfigurationPropertyHolder>().Singleton().Use(configuration_property_holder);
                cfg.For <FileSystemAccess>().Singleton().Use(context => new DotNetFileSystemAccess(configuration_property_holder));
                cfg.For <Database>().Singleton().Use(context => DatabaseBuilder.build(context.GetInstance <FileSystemAccess>(), configuration_property_holder));
                cfg.For <KnownFolders>().Singleton().Use(context => KnownFoldersBuilder.build(context.GetInstance <FileSystemAccess>(), configuration_property_holder));
                cfg.For <LogFactory>().Singleton().Use <MultipleLoggerLogFactory>();
                //cfg.For<Logger>().Singleton().Use(context => LogBuilder.build(context.GetInstance<FileSystemAccess>(), configuration_property_holder));
                cfg.For <Logger>().Use(multiLogger);
                cfg.For <CryptographicService>().Singleton().Use <MD5CryptographicService>();
                cfg.For <DatabaseMigrator>().Singleton().Use(context => new DefaultDatabaseMigrator(context.GetInstance <Database>(), context.GetInstance <CryptographicService>(), configuration_property_holder));
                cfg.For <VersionResolver>().Singleton().Use(
                    context => VersionResolverBuilder.build(context.GetInstance <FileSystemAccess>(), configuration_property_holder));
                cfg.For <EnvironmentSet>().Singleton().Use(new DefaultEnvironmentSet(configuration_property_holder));
                cfg.For <Initializer>().Singleton().Use <FileSystemInitializer>();
            });

            // forcing a build of database to initialize connections so we can be sure server/database have values
            Database database = container.GetInstance <Database>();

            database.initialize_connections(configuration_property_holder);
            configuration_property_holder.ServerName       = database.server_name;
            configuration_property_holder.DatabaseName     = database.database_name;
            configuration_property_holder.ConnectionString = database.connection_string;

            return(new StructureMapContainer(container));
        }
Ejemplo n.º 2
0
        public void should_never_contain_colons()
        {
            var config = new DefaultConfiguration
            {
                DatabaseName = "DaDatabase",
                OutputPath   = "/tmp/rh",
                ServerName   = "tcp:database.domain.domain"
            };
            var fileSystem = new DotNetFileSystemAccess(config);

            var known_folders = KnownFoldersBuilder.build(fileSystem, config);

            StringAssert.DoesNotContain(":", known_folders.change_drop.folder_full_path);
        }
Ejemplo n.º 3
0
        private static InversionContainer build_items_for_container(ConfigurationPropertyHolder configuration_property_holder)
        {
            configuration_property_holder.DatabaseType = DatabaseTypeSynonyms.convert_database_type_synonyms(configuration_property_holder.DatabaseType);

            set_up_current_mappings(configuration_property_holder);

            Logger multi_logger = GetMultiLogger(configuration_property_holder);

            var file_system = new DotNetFileSystemAccess(configuration_property_holder);

            var database = DatabaseBuilder.build(file_system, configuration_property_holder);

            // forcing a build of database to initialize connections so we can be sure server/database have values
            database.initialize_connections(configuration_property_holder);
            configuration_property_holder.ServerName       = database.server_name;
            configuration_property_holder.DatabaseName     = database.database_name;
            configuration_property_holder.ConnectionString = database.connection_string;

            var known_folders    = KnownFoldersBuilder.build(file_system, configuration_property_holder);
            var log_factory      = new MultipleLoggerLogFactory();
            var crypto_service   = new MD5CryptographicService();
            var hash_generator   = new DefaultHashGenerator(crypto_service);
            var db_migrator      = new DefaultDatabaseMigrator(database, hash_generator, configuration_property_holder);
            var version_resolver = VersionResolverBuilder.build(file_system, configuration_property_holder);
            var environment_set  = new DefaultEnvironmentSet(configuration_property_holder);
            var initializer      = new FileSystemInitializer(known_folders);

            HardcodedContainer.Register <ConfigurationPropertyHolder>(configuration_property_holder);
            HardcodedContainer.Register <FileSystemAccess>(file_system);
            HardcodedContainer.Register <Database>(database);
            HardcodedContainer.Register <KnownFolders>(known_folders);
            HardcodedContainer.Register <LogFactory>(log_factory);
            HardcodedContainer.Register <Logger>(multi_logger);
            HardcodedContainer.Register <CryptographicService>(crypto_service);
            HardcodedContainer.Register <DatabaseMigrator>(db_migrator);
            HardcodedContainer.Register <VersionResolver>(version_resolver);
            HardcodedContainer.Register <EnvironmentSet>(environment_set);
            HardcodedContainer.Register <Initializer>(initializer);


            return(HardcodedContainer.Instance);
        }