SimpleTomlConfig 1.1.0

dotnet add package SimpleTomlConfig --version 1.1.0
                    
NuGet\Install-Package SimpleTomlConfig -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SimpleTomlConfig" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SimpleTomlConfig" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="SimpleTomlConfig" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SimpleTomlConfig --version 1.1.0
                    
#r "nuget: SimpleTomlConfig, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SimpleTomlConfig@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SimpleTomlConfig&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=SimpleTomlConfig&version=1.1.0
                    
Install as a Cake Tool

SimpleTomlConfig

SimpleTomlConfig는 TOML 형식의 설정 파일을 쉽게 관리할 수 있게 해주는 제네릭 클래스입니다.

특징

  • TOML 파일을 자동으로 로드하고 저장합니다.
  • 설정 파일이 없을 경우 기본 설정으로 새 파일을 생성합니다.
  • 제네릭을 사용하여 다양한 설정 클래스에 적용할 수 있습니다.

주의사항

  • 설정 파일이 존재하지 않으면 기본값으로 새 파일이 생성됩니다.
  • Save() 메서드를 호출하지 않으면 변경사항이 파일에 저장되지 않습니다.
  • TOML 파일의 키 이름은 프로퍼티 이름과 일치해야 합니다.
  • 다른 키 이름을 사용하려면 [TomlProperty("key")]를 사용합니다.
  • 이름을 생략한 [TomlProperty], [TomlSection]는 class/property 이름을 사용합니다.
  • 객체를 TOML section으로 저장하려면 [TomlSection("sectionName")] 또는 [TomlSection]를 사용합니다.
  • TOML 로드/저장에서 제외하려면 [TomlIgnore]를 사용합니다.
  • TomlConfig<TClass>를 상속받은 객체의 설정파일 이름은 configPath를 설정하지 않은 경우 {TClass}.toml입니다.

사용 방법

1. 설정 클래스 정의

using SimpleTomlConfig;

[TomlSection]
public class MyConfig(string? configPath = null) : TomlConfig<MyConfig>(configPath)
{
    [TomlProperty]
    public string? Name { get; set; }

    [TomlProperty("age")]
    public int Age { get; set; }

    [TomlIgnore]
    public string RuntimeOnlyValue { get; set; } = "";

    [TomlProperty("myType")]
    public MyEnum MyType { get; set; }

    [TomlSection("device")]
    public DeviceConfig Device { get; set; } = new();
}

public class DeviceConfig
{
    [TomlProperty]
    public string Port { get; set; } = "COM1";
}

2. 설정 객체 생성

var config = new MyConfig();
var customConfig = new MyConfig("path/to/custom/config.toml");

3. 설정 값 변경 및 저장

config.Name = "Mr.Kim";
config.Save();

4. 설정 값 다시 불러오기

config.Load();

5. 다른 경로로 설정 저장

config.SaveAs("path/to/new/config.toml");
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.1.0 159 5/11/2026
1.0.0 131 5/11/2026

Initial release with TomlConfig, TomlSection, TomlProperty, TomlIgnore, Load, Save, and SaveAs support.