Trico 1.1.7
dotnet add package Trico --version 1.1.7
NuGet\Install-Package Trico -Version 1.1.7
<PackageReference Include="Trico" Version="1.1.7" />
paket add Trico --version 1.1.7
#r "nuget: Trico, 1.1.7"
// Install Trico as a Cake Addin
#addin nuget:?package=Trico&version=1.1.7
// Install Trico as a Cake Tool
#tool nuget:?package=Trico&version=1.1.7
Trico
trico is a simple configuration library for your .net projects
Status
main | |
develop | |
unit tests | |
version | |
downloads | |
license | |
size |
Supported providers
in-memory | ✓ |
file | ✓ |
environment variables | ✓ |
api | ✕ |
database | ✕ |
Usage
Step 1. Add Trico services to the service collection
You start with adding trico
services to the IServiceCollection
serviceCollection.AddConfiguration();
Step 2. Configure required providers
Add required providers to the IServiceCollection
.
Important! Configurations are looked up in providers in the order of registration in service collection.
In-Memory provider
In-Memory configuration provider is a non-persistent short-term storage. Used to work with configurations that are set and used in runtime. In coupe with other providers can also be used as a default application configuration
To add provider to your application, use:
serviceProvider.AddInMemoryProvider();
Initial set of configurations can be set by passing Dictionary<string, string>
into the method:
Dictionary<string, string> defaultConfigs = GetDefaultConfigs();
serviceProvider.AddInMemoryProvider(defaultConfigs);
File provider
File configuration provider is a persistent long-term storage.
To add provider to your application, use:
serviceCollection.AddFileProvider();
Load params:
name | description |
---|---|
config-filepath | path to the file where configurations are stored |
Environment variable provider
Environment variable configuration provider is a non-persistent long-term storage. Allows to import application configurations from environment variables, but can't update them.
To add provider to your application, use:
serviceCollection.AddEnvironmentVariableProvider();
Load params:
name | description |
---|---|
prefix | variable name prefix. Used to narrow down the scope of imported variables |
Step 3. Explicitly load configurations
Load configurations either asynchronously:
Dictionary<string, string> options = new Dictionary<string, string>() {
{ "config-filepath", "..." },
{ "prefix", "" },
}
await config.LoadAsync(options, default);
Step 4. Use configurations
var value = config["key"];
More info
refer to the Playground project
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.Extensions.DependencyInjection (>= 7.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Primitives (>= 7.0.0)
- Newtonsoft.Json (>= 13.0.2)
- YamlDotNet (>= 12.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.