mirror of
https://github.com/volodymyrsmirnov/MalwareMultiScan.git
synced 2025-08-24 05:22:22 +00:00
29 lines
1022 B
C#
29 lines
1022 B
C#
|
using System.IO;
|
||
|
using MalwareMultiScan.Api.Data.Configuration;
|
||
|
using Microsoft.Extensions.Configuration;
|
||
|
using YamlDotNet.Serialization;
|
||
|
using YamlDotNet.Serialization.NamingConventions;
|
||
|
|
||
|
namespace MalwareMultiScan.Api.Services
|
||
|
{
|
||
|
public class BackendConfigurationReader
|
||
|
{
|
||
|
public BackendConfigurationReader(IConfiguration configuration)
|
||
|
{
|
||
|
var configurationPath = configuration.GetValue<string>("BackendsConfiguration");
|
||
|
|
||
|
if (!File.Exists(configurationPath))
|
||
|
throw new FileNotFoundException("Missing BackendsConfiguration YAML file", configurationPath);
|
||
|
|
||
|
var configurationContent = File.ReadAllText(configurationPath);
|
||
|
|
||
|
var deserializer = new DeserializerBuilder()
|
||
|
.WithNamingConvention(CamelCaseNamingConvention.Instance)
|
||
|
.Build();
|
||
|
|
||
|
Backends = deserializer.Deserialize<BackendConfiguration[]>(configurationContent);
|
||
|
}
|
||
|
|
||
|
public BackendConfiguration[] Backends { get; }
|
||
|
}
|
||
|
}
|