Beispiel #1
0
        public BtcTransmuterOptions(IConfiguration configuration, IWebHostEnvironment hostingEnvironment, ILogger logger)
        {
            RootPath = configuration.GetValue("RootPath", "");
            DatabaseConnectionString      = configuration.GetValue <string>("Database");
            DataProtectionDir             = configuration.GetValue <string>("DataProtectionDir");
            DataProtectionApplicationName = configuration.GetValue <string>("DataProtectionApplicationName");
            DatabaseType = configuration.GetValue <DatabaseType>("DatabaseType", DatabaseType.Sqlite);
            UseDatabaseColumnEncryption = configuration.GetValue <bool>("UseDatabaseColumnEncryption", false);
            ExtensionsDir = configuration.GetValue <string>("ExtensionsDir",
                                                            Path.Combine(hostingEnvironment.ContentRootPath, "Extensions"));

            if (DatabaseType == DatabaseType.Sqlite)
            {
                var dbFilePath = DatabaseConnectionString.Substring(DatabaseConnectionString.IndexOf("Data Source=") + "Data Source=".Length);
                dbFilePath = dbFilePath.Substring(0, dbFilePath.IndexOf(";"));

                if (!string.IsNullOrEmpty(Path.GetDirectoryName(dbFilePath)))
                {
                    if (DataProtectionDir == null)
                    {
                        DataProtectionDir = Path.GetDirectoryName(dbFilePath);
                    }
                    Directory.CreateDirectory(Path.GetDirectoryName(dbFilePath));
                }
            }
            logger.LogWarning($"{JObject.FromObject(this)}");
        }
Beispiel #2
0
        public BtcTransmuterOptions(IConfiguration configuration, IHostingEnvironment hostingEnvironment, ILogger logger)
        {
            DatabaseConnectionString = configuration.GetValue <string>("Database");
            DataProtectionDir        = configuration.GetValue <string>("DataProtectionDir");
            DatabaseType             = configuration.GetValue <DatabaseType>("DatabaseType", DatabaseType.Sqlite);
            ExtensionsDir            = configuration.GetValue <string>("ExtensionsDir",
                                                                       Path.Combine(hostingEnvironment.ContentRootPath, "Extensions"));

            if (DatabaseType == DatabaseType.Sqlite)
            {
                var dbFilePath = DatabaseConnectionString.Substring(DatabaseConnectionString.IndexOf("Data Source=") + "Data Source=".Length);
                dbFilePath = dbFilePath.Substring(0, dbFilePath.IndexOf(";"));

                if (!string.IsNullOrEmpty(Path.GetDirectoryName(dbFilePath)))
                {
                    if (DataProtectionDir == null)
                    {
                        DataProtectionDir = Path.GetDirectoryName(dbFilePath);
                    }
                    Directory.CreateDirectory(Path.GetDirectoryName(dbFilePath));
                }
            }

            logger.LogWarning($"Connecting to {DatabaseType} db with: {DatabaseConnectionString}");
            logger.LogWarning($"Extensions Dir: {ExtensionsDir}, Data Protection Dir: {DataProtectionDir}");
        }