to get the tenant id you need access to the HttpContext to get the header value. this means the constructor of the service will need to read the settings, rather than passed.
I probably create a new configuration service that fetched the tenantid from the context, and exposed setting for that context. trival implementation using:
public class TenantSettings
{
private IHttpContextAccessor httpContextAccessor;
private IConfiguration config;
private string tentantHeaderName;
private string TenantId => httpContextAccessor.HttpContext?.Request.Headers[tenantHeaderName] ?? "";
public TentantSettings(IHttpContextAccessor httpContextAccessor, IConfiguration config)
{
this.httpContextAccessor = httpContextAccessor;
this.config = config;
tenantHeaderName = config.GetValue<string>("tenantHeaderName") ?? "defaultname";
}
public string GetStringValue(string key)
{
return config.GetValue<string>($"{TenantId}:{key}");
}
public string GetConnectionValue(string key)
{
return config.GetValue<string>($"ConnectionStrings:{TenantId}:{key}");
}
}
just inject into services to access the settings. you could use different settings stores, prefix, postfix, whatever you want.