using System; using System.Text.Json.Serialization; namespace Kit.Helpers.SqlHelperAbstract { public enum ConnectionStringType { Undefined = 0, Postgres = 1, SQLite = 2, } public interface IConnectionString { ConnectionStringType Type { get; } string Value { get; } ISqlHelper GetSqlHelper(); } public class ConnectionString : IConnectionString { public ConnectionStringType Type { get; set; } = ConnectionStringType.Undefined; private string _value = string.Empty; public string Value { get => _value; set => _value = value.ServerMapPath(); } public virtual ISqlHelper GetSqlHelper() { switch (Type) { case ConnectionStringType.Postgres: return Postgres.SqlHelper.Instance; case ConnectionStringType.SQLite: return SQLite.SqlHelper.Instance; default: throw new NotImplementedException(); } } public static SqlHelperFluent PrepareExecute(string sqlText) { return new ConnectionString().PrepareExecute(sqlText); } } public static class ConnectionStringExtensions { public static SqlHelperFluent PrepareExecute(this IConnectionString connectionString, string sqlText) { return new SqlHelperFluent(connectionString, sqlText); } public static SqlHelperFluent PrepareExecute(this IConnectionString connectionString, string sqlText) { return new SqlHelperFluent(connectionString, sqlText); } } }