private void ApplyAppSetting(ApplicationConfiguration configuration, XElement appSettings, string key, string value)
{
string xpath = $"add[@key='{key}']";
XElement appSetting = appSettings.XPathSelectElement(xpath);
if (configuration.Secrets.Contains(value))
{
appSetting?.Remove();
}
else
{
if (appSetting == null)
{
appSetting = new XElement("add", new XAttribute("key", key), new XAttribute("value", value));
appSettings.Add(appSetting);
}
else
{
appSetting.SetAttributeValue("value", value);
}
}
}
}