[CHANGE] Moved to appsettings settings
This commit is contained in:
@@ -1,12 +1,29 @@
|
||||
using DotBased.Logging;
|
||||
using DotBased.Logging.MEL;
|
||||
using DotBased.Logging.Serilog;
|
||||
using Manager.App.Models.Settings;
|
||||
using Serilog;
|
||||
|
||||
namespace Manager.App;
|
||||
|
||||
public static class DependencyInjection
|
||||
{
|
||||
public static void SetupSettings(this WebApplicationBuilder builder)
|
||||
{
|
||||
builder.Services.AddOptions<LibrarySettings>()
|
||||
.Bind(builder.Configuration.GetSection("Library"))
|
||||
.ValidateDataAnnotations()
|
||||
.PostConfigure(settings =>
|
||||
{
|
||||
settings.Path = settings.Path.Replace("{workdir}", Environment.CurrentDirectory, StringComparison.InvariantCultureIgnoreCase);
|
||||
})
|
||||
.ValidateOnStart();
|
||||
builder.Services.AddOptions<DownloadSettings>()
|
||||
.Bind(builder.Configuration.GetSection("Downloads"))
|
||||
.ValidateDataAnnotations()
|
||||
.ValidateOnStart();
|
||||
}
|
||||
|
||||
public static void SetupLogging(this WebApplicationBuilder builder)
|
||||
{
|
||||
var isDevelopment = builder.Environment.IsDevelopment();
|
||||
|
10
Manager.App/Models/Settings/DownloadSettings.cs
Normal file
10
Manager.App/Models/Settings/DownloadSettings.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Manager.App.Models.Settings;
|
||||
|
||||
public class DownloadSettings
|
||||
{
|
||||
[ConfigurationKeyName("MaxConcurrentDownloads")]
|
||||
[Range(-1, 20)]
|
||||
public int MaxConcurrentDownloads { get; set; }
|
||||
}
|
10
Manager.App/Models/Settings/LibrarySettings.cs
Normal file
10
Manager.App/Models/Settings/LibrarySettings.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Manager.App.Models.Settings;
|
||||
|
||||
public class LibrarySettings
|
||||
{
|
||||
[ConfigurationKeyName("Path")]
|
||||
[Required]
|
||||
public required string Path { get; set; }
|
||||
}
|
@@ -8,10 +8,10 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddRazorComponents()
|
||||
.AddInteractiveServerComponents();
|
||||
|
||||
builder.SetupLogging();
|
||||
|
||||
/* App setup */
|
||||
|
||||
builder.SetupLogging();
|
||||
builder.SetupSettings();
|
||||
|
||||
/* MudBlazor */
|
||||
builder.Services.AddMudServices();
|
||||
|
@@ -16,5 +16,11 @@
|
||||
"Default": "Trace",
|
||||
"Microsoft.AspNetCore": "Debug"
|
||||
}
|
||||
},
|
||||
"Library": {
|
||||
"Path": "{workdir}/"
|
||||
},
|
||||
"Downloads": {
|
||||
"MaxConcurrentDownloads": 5
|
||||
}
|
||||
}
|
||||
|
@@ -17,5 +17,11 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
"Library": {
|
||||
"Path": "{workdir}/Library"
|
||||
},
|
||||
"Downloads": {
|
||||
"MaxConcurrentDownloads": 5
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user