[CHANGE] Moved to appsettings settings
This commit is contained in:
@@ -1,12 +1,29 @@
|
|||||||
using DotBased.Logging;
|
using DotBased.Logging;
|
||||||
using DotBased.Logging.MEL;
|
using DotBased.Logging.MEL;
|
||||||
using DotBased.Logging.Serilog;
|
using DotBased.Logging.Serilog;
|
||||||
|
using Manager.App.Models.Settings;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace Manager.App;
|
namespace Manager.App;
|
||||||
|
|
||||||
public static class DependencyInjection
|
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)
|
public static void SetupLogging(this WebApplicationBuilder builder)
|
||||||
{
|
{
|
||||||
var isDevelopment = builder.Environment.IsDevelopment();
|
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()
|
builder.Services.AddRazorComponents()
|
||||||
.AddInteractiveServerComponents();
|
.AddInteractiveServerComponents();
|
||||||
|
|
||||||
builder.SetupLogging();
|
|
||||||
|
|
||||||
/* App setup */
|
/* App setup */
|
||||||
|
builder.SetupLogging();
|
||||||
|
builder.SetupSettings();
|
||||||
|
|
||||||
/* MudBlazor */
|
/* MudBlazor */
|
||||||
builder.Services.AddMudServices();
|
builder.Services.AddMudServices();
|
||||||
|
@@ -16,5 +16,11 @@
|
|||||||
"Default": "Trace",
|
"Default": "Trace",
|
||||||
"Microsoft.AspNetCore": "Debug"
|
"Microsoft.AspNetCore": "Debug"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Library": {
|
||||||
|
"Path": "{workdir}/"
|
||||||
|
},
|
||||||
|
"Downloads": {
|
||||||
|
"MaxConcurrentDownloads": 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,5 +17,11 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"Library": {
|
||||||
|
"Path": "{workdir}/Library"
|
||||||
|
},
|
||||||
|
"Downloads": {
|
||||||
|
"MaxConcurrentDownloads": 5
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user