Polianin Nikita
993e66a084
All checks were successful
.NET Test Pipeline / build-and-test (push) Successful in 3m46s
33 lines
995 B
C#
33 lines
995 B
C#
using Mirea.Api.DataAccess.Persistence.Common;
|
|
using Mirea.Api.Endpoint.Configuration.General.Attributes;
|
|
using Mirea.Api.Endpoint.Configuration.General.Interfaces;
|
|
using System;
|
|
using System.Text.Json.Serialization;
|
|
|
|
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; }
|
|
|
|
[JsonIgnore]
|
|
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);
|
|
} |