2024-05-30 20:25:21 +03:00
|
|
|
|
using System;
|
|
|
|
|
using Mirea.Api.DataAccess.Persistence.Common;
|
|
|
|
|
using Mirea.Api.Endpoint.Configuration.General.Attributes;
|
2024-05-28 06:38:24 +03:00
|
|
|
|
using Mirea.Api.Endpoint.Configuration.General.Interfaces;
|
|
|
|
|
|
|
|
|
|
namespace Mirea.Api.Endpoint.Configuration.General.Settings;
|
|
|
|
|
|
|
|
|
|
[RequiredSettings]
|
|
|
|
|
public class DbSettings : IIsConfigured
|
|
|
|
|
{
|
|
|
|
|
public enum DatabaseEnum
|
|
|
|
|
{
|
|
|
|
|
Mysql,
|
|
|
|
|
Sqlite,
|
|
|
|
|
PostgresSql
|
|
|
|
|
}
|
|
|
|
|
public DatabaseEnum TypeDatabase { get; set; }
|
|
|
|
|
public required string ConnectionStringSql { get; set; }
|
|
|
|
|
|
2024-05-30 20:25:21 +03:00
|
|
|
|
public DatabaseProvider DatabaseProvider =>
|
|
|
|
|
TypeDatabase switch
|
|
|
|
|
{
|
|
|
|
|
DatabaseEnum.PostgresSql => DatabaseProvider.Postgresql,
|
|
|
|
|
DatabaseEnum.Mysql => DatabaseProvider.Mysql,
|
|
|
|
|
DatabaseEnum.Sqlite => DatabaseProvider.Sqlite,
|
|
|
|
|
_ => throw new ArgumentOutOfRangeException()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public bool IsConfigured() =>
|
|
|
|
|
!string.IsNullOrEmpty(ConnectionStringSql);
|
2024-05-28 06:38:24 +03:00
|
|
|
|
}
|