More work on SeqBackgroundService, next step is tests for it.
This commit is contained in:
parent
a139b1ad08
commit
67207cf90b
27 changed files with 237 additions and 190 deletions
|
|
@ -1,6 +1,4 @@
|
|||
using Core.Configurations.SmartConfigProvider;
|
||||
|
||||
namespace Core.Configurations.SmartConfiguration;
|
||||
namespace Core.Configurations.SmartConfigProvider;
|
||||
public interface IConfigurationRepository
|
||||
{
|
||||
string ConnectionString { get; set; }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System.Data;
|
||||
using Core.Configurations.SmartConfiguration;
|
||||
using Insight.Database;
|
||||
|
||||
namespace Core.Configurations.SmartConfigProvider.Repositories;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace Core.Configurations.SmartConfig
|
||||
namespace Core.Configurations.SmartConfigProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for adding smart configuration providers to IConfigurationBuilder.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace Core.Configurations.SmartConfig
|
||||
namespace Core.Configurations.SmartConfigProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Configuration options for setting up smart configuration providers.
|
||||
|
|
@ -6,7 +6,7 @@ namespace Core.Configurations.SmartConfig
|
|||
/// </summary>
|
||||
public class SmartConfigOptions
|
||||
{
|
||||
private SmartConfiguration.IConfigurationRepository _repository;
|
||||
private IConfigurationRepository _repository;
|
||||
internal string _configKey;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -17,7 +17,7 @@ namespace Core.Configurations.SmartConfig
|
|||
public SmartConfigOptions UsePostgres(string configKey)
|
||||
{
|
||||
_configKey = configKey;
|
||||
_repository = new Configurations.SmartConfigProvider.Repositories.PostgresConfigurationRepository();
|
||||
_repository = new Repositories.PostgresConfigurationRepository();
|
||||
return this;
|
||||
}
|
||||
/// <summary>
|
||||
|
|
@ -34,12 +34,12 @@ namespace Core.Configurations.SmartConfig
|
|||
/// </summary>
|
||||
/// <param name="repository">The configuration repository to use</param>
|
||||
/// <returns>The configuration options instance for method chaining</returns>
|
||||
public SmartConfigOptions UseRepository(SmartConfiguration.IConfigurationRepository repository)
|
||||
public SmartConfigOptions UseRepository(IConfigurationRepository repository)
|
||||
{
|
||||
_repository = repository;
|
||||
return this;
|
||||
}
|
||||
|
||||
internal SmartConfiguration.IConfigurationRepository GetRepository() => _repository;
|
||||
internal IConfigurationRepository GetRepository() => _repository;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ using Core.Exceptions;
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Core.Configurations.SmartConfig
|
||||
namespace Core.Configurations.SmartConfigProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Configuration provider that loads configuration from a smart configuration source (e.g. database).
|
||||
|
|
@ -22,7 +22,7 @@ namespace Core.Configurations.SmartConfig
|
|||
string _path;
|
||||
IConfigurationBuilder _builder;
|
||||
|
||||
Newtonsoft.Json.Linq.JObject _configuration;
|
||||
JObject _configuration;
|
||||
SmartConfigOptions _smartConfigOptions;
|
||||
|
||||
public SmartConfigProvider() { }
|
||||
|
|
@ -59,7 +59,7 @@ namespace Core.Configurations.SmartConfig
|
|||
using (StreamReader file = File.OpenText(_path))
|
||||
using (JsonTextReader reader = new JsonTextReader(file))
|
||||
{
|
||||
var jsonConfiguration = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.Linq.JToken.ReadFrom(reader);
|
||||
var jsonConfiguration = (JObject)JToken.ReadFrom(reader);
|
||||
|
||||
_connectionString = jsonConfiguration.SelectToken($"ConnectionStrings.{_configKey}")?.ToString();
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ namespace Core.Configurations.SmartConfig
|
|||
|
||||
}
|
||||
|
||||
public Newtonsoft.Json.Linq.JObject Configuration()
|
||||
public JObject Configuration()
|
||||
{
|
||||
return _configuration;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue