Exemple #1
0
        /// <summary>
        /// Creates and returns a DB initializer according to options defined in the <paramref name="initAction"/> function.
        /// </summary>
        /// <param name="initAction">The action where we can set different options of the create DbInitializer.</param>
        /// <param name="loggerFactory">The logger factory.</param>
        /// <returns>DbInitializer.</returns>
        public static DbInitializer Create(Action <IDbUtilsOptions> initAction, ILoggerFactory loggerFactory = null)
        {
            var options = new DbInitializerOptions(loggerFactory);

            initAction?.Invoke(options);

            if (options.DatasetImporter == null)
            {
                options.DatasetImporter = new JsonDatasetImporter(options.LoggerFactory);
            }

            if (options.Unpacker == null)
            {
                options.Unpacker = new FileFolderPacker(options.SeedDataFolder);
            }

            return(new DbInitializer(options));
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DbInitializer"/> class.
 /// </summary>
 /// <param name="options">The options of DB initializer</param>
 public DbInitializer(DbInitializerOptions options)
 {
     _dbImporter = new DbImporter(options.DbWriter, options.DatasetImporter, options.Unpacker);
     _options    = options;
 }