Sicherung

This commit is contained in:
Maier Stephan SI
2023-01-02 04:33:49 +01:00
parent bea46135fd
commit d01747f75a
284 changed files with 6106 additions and 65112 deletions

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Specialized;
using System.Configuration;
namespace Config.Net.Stores
{
/// <summary>
/// Standard app.config (web.config) configuration store. Read-only.
/// </summary>
class AppConfigStore : IConfigStore
{
public string Name => "App.config";
public bool CanRead => true;
public bool CanWrite => false;
public string? Read(string key)
{
if(key == null) return null;
//first, look at appsettings and connection strings
string? value = ConfigurationManager.AppSettings[key] ?? ConfigurationManager.ConnectionStrings[key]?.ConnectionString;
if(value == null)
{
int idx = key.IndexOf('.');
if(idx != -1)
{
string sectionName = key.Substring(0, idx);
if(ConfigurationManager.GetSection(sectionName) is NameValueCollection nvsc)
{
string keyName = key.Substring(idx + 1);
value = nvsc[keyName];
}
}
}
return value;
}
public void Write(string key, string? value) => throw new NotSupportedException();
public void Dispose()
{
}
}
}