Use file scoped namepace

This commit is contained in:
2022-12-22 15:29:53 +01:00
parent 27bf5f0b24
commit 6d7e447ccc
51 changed files with 886 additions and 937 deletions

View File

@@ -2,31 +2,30 @@
using GerstITS.Web.Api.Builder;
using Microsoft.Extensions.Configuration;
namespace GerstITS.Examples.Api.Configurations
namespace GerstITS.Examples.Api.Configurations;
internal sealed class CorsPolicyConfiguration : ICorsPolicy, GerstITS.System.Configurations.IConfiguration
{
internal sealed class CorsPolicyConfiguration : ICorsPolicy, GerstITS.System.Configurations.IConfiguration
#region Constructors
public CorsPolicyConfiguration(string parentPrefix, Microsoft.Extensions.Configuration.IConfiguration configuration)
{
#region Constructors
var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}";
public CorsPolicyConfiguration(string parentPrefix, Microsoft.Extensions.Configuration.IConfiguration configuration)
{
var prefix = $"{parentPrefix}:{this.ToConfigurationPrefix()}";
AllowCredentials = configuration.GetValue<bool>($"{prefix}:{nameof(AllowCredentials)}", false);
AllowedOrigins = configuration.GetSection($"{prefix}:{nameof(AllowedOrigins)}").Get<string[]>() ?? new string[0];
AllowedHeaders = configuration.GetSection($"{prefix}:{nameof(AllowedHeaders)}").Get<string[]>() ?? new string[0];
AllowedMethods = configuration.GetSection($"{prefix}:{nameof(AllowedMethods)}").Get<string[]>() ?? new string[0];
}
#endregion
#region ICorsPolicy
public bool AllowCredentials { get; }
public string[] AllowedOrigins { get; set; }
public string[] AllowedHeaders { get; set; }
public string[] AllowedMethods { get; set; }
#endregion
AllowCredentials = configuration.GetValue<bool>($"{prefix}:{nameof(AllowCredentials)}", false);
AllowedOrigins = configuration.GetSection($"{prefix}:{nameof(AllowedOrigins)}").Get<string[]>() ?? new string[0];
AllowedHeaders = configuration.GetSection($"{prefix}:{nameof(AllowedHeaders)}").Get<string[]>() ?? new string[0];
AllowedMethods = configuration.GetSection($"{prefix}:{nameof(AllowedMethods)}").Get<string[]>() ?? new string[0];
}
#endregion
#region ICorsPolicy
public bool AllowCredentials { get; }
public string[] AllowedOrigins { get; set; }
public string[] AllowedHeaders { get; set; }
public string[] AllowedMethods { get; set; }
#endregion
}