Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 1022 Bytes

README.md

File metadata and controls

46 lines (35 loc) · 1022 Bytes

Settings Generator for ASP.NET

Actions NuGet

Installation

dotnet add package wk.SettingsGenerator

Usage

  1. Add configuration into appsettings.json
{
    "Alfresco": {
        "Url": "http://localhost:8080",
        "User": "admin",
        "Password": "admin"
    },
    "Database": {
        "ConnectionString": "Host=localhost"
    }
}
  1. Generate settings class
[AppSettings(FileName = "appsettings.json")]
public partial class AppSettings { }
  1. Load settings
public void ConfigureServices(IServiceCollection services) {
    var settings = Configuration.Get<AppSettings>();

    Console.WriteLine(settings.Alfresco.Url);
    Console.WriteLine(settings.Database.ConnectionString);
    ...
}