https://github.com/wk-j/settings-generator
APP settings generator for ASP.NET Core
https://github.com/wk-j/settings-generator
Last synced: 26 days ago
JSON representation
APP settings generator for ASP.NET Core
- Host: GitHub
- URL: https://github.com/wk-j/settings-generator
- Owner: wk-j
- Created: 2020-11-22T09:16:12.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-11-22T08:58:10.000Z (over 3 years ago)
- Last Synced: 2025-02-08T18:15:18.580Z (3 months ago)
- Language: C#
- Homepage:
- Size: 27.3 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Settings Generator for ASP.NET
[](https://github.com/wk-j/dotnet-settings-generator/actions)
[](https://www.nuget.org/packages/wk.SettingsGenerator)## Installation
```bash
dotnet add package wk.SettingsGenerator
```## Usage
1. Add configuration into `appsettings.json`
```json
{
"Alfresco": {
"Url": "http://localhost:8080",
"User": "admin",
"Password": "admin"
},
"Database": {
"ConnectionString": "Host=localhost"
}
}
```2. Generate settings class
```csharp
[AppSettings(FileName = "appsettings.json")]
public partial class AppSettings { }
```3. Load settings
```csharp
public void ConfigureServices(IServiceCollection services) {
var settings = Configuration.Get();Console.WriteLine(settings.Alfresco.Url);
Console.WriteLine(settings.Database.ConnectionString);
...
}
```