32 lines
818 B
C#
32 lines
818 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml;
|
|
|
|
namespace BeWo.Service.Core
|
|
{
|
|
public static class MergedConfig
|
|
{
|
|
public static string GetSetting(string key)
|
|
{
|
|
// 1. Versuche, aus AppSettings.local.config zu lesen
|
|
var localConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Web.Secrets.config");
|
|
if (File.Exists(localConfigPath))
|
|
{
|
|
var xml = new XmlDocument();
|
|
xml.Load(localConfigPath);
|
|
var node = xml.SelectSingleNode($"/appSettings/add[@key='{key}']");
|
|
if (node is XmlElement element)
|
|
return element.GetAttribute("value");
|
|
}
|
|
|
|
// 2. Fallback: Standard-AppSettings
|
|
return ConfigurationManager.AppSettings[key];
|
|
}
|
|
}
|
|
}
|