This commit is contained in:
skidoodle 2024-03-13 00:33:46 +01:00
commit e124a47765
19374 changed files with 9806149 additions and 0 deletions

View file

@ -0,0 +1,50 @@
using System;
using System.Configuration;
namespace Kreta.Naplo.Configuration
{
public class CorsConfiguration : ConfigurationSection, ICorsConfiguration
{
const string SectionName = "CorsConfiguration";
static Lazy<CorsConfiguration> instance;
public static CorsConfiguration Instance
{
get
{
return instance.Value;
}
}
[ConfigurationProperty(nameof(IsEnabled), IsRequired = true)]
public bool IsEnabled => (bool)this[nameof(IsEnabled)];
[ConfigurationProperty(nameof(Urls), IsRequired = true)]
public string Urls => (string)this[nameof(Urls)];
[ConfigurationProperty(nameof(Headers), IsRequired = true)]
public string Headers => (string)this[nameof(Headers)];
[ConfigurationProperty(nameof(Methods), IsRequired = true)]
public string Methods => (string)this[nameof(Methods)];
[ConfigurationProperty(nameof(SupportsCredentials), IsRequired = true)]
public bool SupportsCredentials => (bool)this[nameof(SupportsCredentials)];
static CorsConfiguration()
{
instance = new Lazy<CorsConfiguration>(() =>
{
var section = (CorsConfiguration)ConfigurationManager.GetSection(SectionName);
if (section == null)
{
throw new ConfigurationErrorsException($"{SectionName} configuration section was not found");
}
return section;
});
}
}
}