34 lines
902 B
C#
34 lines
902 B
C#
using System;
|
|
using APT.Infrastructure.Api;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
namespace APT.Infrastructure.EF.Infrastructure
|
|
{
|
|
public interface IConnectionResolver
|
|
{
|
|
string GetConnection();
|
|
|
|
}
|
|
|
|
public class HttpHeaderSqlConnectionResolver : IConnectionResolver
|
|
{
|
|
private readonly TenantInfo tenantInfo;
|
|
private readonly IConfiguration configuration;
|
|
|
|
public HttpHeaderSqlConnectionResolver(TenantInfo tenantInfo, IConfiguration configuration)
|
|
{
|
|
this.tenantInfo = tenantInfo;
|
|
this.configuration = configuration;
|
|
}
|
|
public string GetConnection()
|
|
{
|
|
var connectionString = string.Empty;
|
|
if (!string.IsNullOrEmpty(this.tenantInfo?.Conn))
|
|
{
|
|
return this.tenantInfo?.Conn;
|
|
}
|
|
|
|
return connectionString;
|
|
}
|
|
}
|
|
} |