mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:06:30 +00:00
71 lines
1.9 KiB
C#
71 lines
1.9 KiB
C#
using System.IO;
|
|
using System.Text;
|
|
using Azaion.Common.Extensions;
|
|
using Azaion.Common.Services;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Azaion.Common.DTO.Config;
|
|
|
|
public class AppConfig
|
|
{
|
|
public LoaderClientConfig LoaderClientConfig { get; set; } = null!;
|
|
|
|
public InferenceClientConfig InferenceClientConfig { get; set; } = null!;
|
|
|
|
public GpsDeniedClientConfig GpsDeniedClientConfig { get; set; } = null!;
|
|
|
|
public QueueConfig QueueConfig { get; set; } = null!;
|
|
|
|
public DirectoriesConfig DirectoriesConfig { get; set; } = null!;
|
|
|
|
public AnnotationConfig AnnotationConfig { get; set; } = null!;
|
|
|
|
public UIConfig UIConfig { get; set; } = null!;
|
|
|
|
public AIRecognitionConfig AIRecognitionConfig { get; set; } = null!;
|
|
|
|
public ThumbnailConfig ThumbnailConfig { get; set; } = null!;
|
|
|
|
public MapConfig MapConfig{ get; set; } = null!;
|
|
|
|
public GpsDeniedConfig GpsDeniedConfig { get; set; } = null!;
|
|
|
|
public CameraConfig CameraConfig { get; set; } = null!;
|
|
}
|
|
|
|
public interface IConfigUpdater
|
|
{
|
|
void CheckConfig();
|
|
void Save(AppConfig config);
|
|
}
|
|
|
|
public class ConfigUpdater : IConfigUpdater
|
|
{
|
|
private readonly IConfigurationStore _configStore;
|
|
|
|
public ConfigUpdater(IConfigurationStore configStore)
|
|
{
|
|
_configStore = configStore;
|
|
}
|
|
|
|
public ConfigUpdater() : this(new FileConfigurationStore(Constants.CONFIG_PATH, new PhysicalFileSystem()))
|
|
{
|
|
}
|
|
|
|
public void CheckConfig()
|
|
{
|
|
var exePath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory)!;
|
|
var configFilePath = Path.Combine(exePath, Constants.CONFIG_PATH);
|
|
|
|
if (File.Exists(configFilePath))
|
|
return;
|
|
|
|
Save(Constants.FailsafeAppConfig);
|
|
}
|
|
|
|
public void Save(AppConfig config)
|
|
{
|
|
_ = _configStore.SaveAsync(config);
|
|
}
|
|
}
|