SynesthesiaDev.ConfigLib
2026.902.0
dotnet add package SynesthesiaDev.ConfigLib --version 2026.902.0
NuGet\Install-Package SynesthesiaDev.ConfigLib -Version 2026.902.0
<PackageReference Include="SynesthesiaDev.ConfigLib" Version="2026.902.0" />
<PackageVersion Include="SynesthesiaDev.ConfigLib" Version="2026.902.0" />
<PackageReference Include="SynesthesiaDev.ConfigLib" />
paket add SynesthesiaDev.ConfigLib --version 2026.902.0
#r "nuget: SynesthesiaDev.ConfigLib, 2026.902.0"
#:package SynesthesiaDev.ConfigLib@2026.902.0
#addin nuget:?package=SynesthesiaDev.ConfigLib&version=2026.902.0
#tool nuget:?package=SynesthesiaDev.ConfigLib&version=2026.902.0
⚙️ ConfigLib
Config utility library so I don't have to copy and paste code in all of my projects.
How to use
Create a config record with Codon codec and extend IConfigModel interface
public record Config(string Name, string Ip, int Port) : IConfigModel
{
public static readonly Config DEFAULT = new Config("test", "0.0.0.0", 27533);
public static readonly Codec<Config> CODEC = StructCodec .For<Config>()
.Field("Name", Codecs.STRING, c => c.Name)
.Field("Ip", Codecs.STRING, c => c.Ip)
.Field("Port", Codecs.INT, c => c.Port)
.Build((name, ip, port) => new Config(name, ip, port));
}
Create the ConfigLib instance. Here you can specify stuff like location, the codec and the transcoder (config language) you want to use, along with default value
public static readonly ConfigLib<Config, ISynxElement> CONFIG = ConfigLib.For<Config, ISynxElement>()
.Encoding(Config.CODEC, SynxTranscoder.INSTANCE)
.Location(ConfigLocation.DataFolder("config.synx"))
.Default(Config.DEFAULT)
.Build();
You can additionally add hooks like DirectoryCreatedHook to for example copy additional default files:
.DirectoryCreateHook(location =>
{
Utils.CopyEmbeddedFolder(GetType().Assembly, "Canopy.Core.Resources", location.FolderPath);
})
You can also add simple validation
.Validation(config =>
{
if (config.Port == 25565) return "This port is taken by minecraft..";
return null;
})
Then whenever you want your config loaded, you call Load and access it with CONFIG.Current:
private static void Main(string[] args)
{
CONFIG.Load();
}
You can also set CONFIG.Current to a new value and the file will be automatically saved
【= ❙ 𖥦 ❙ =】
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- SynesthesiaDev.Codon.Codon (>= 2026.902.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.902.0 | 22 | 9/2/2026 |