LtxConfigModel 1.0.0
dotnet add package LtxConfigModel --version 1.0.0
NuGet\Install-Package LtxConfigModel -Version 1.0.0
<PackageReference Include="LtxConfigModel" Version="1.0.0" />
<PackageVersion Include="LtxConfigModel" Version="1.0.0" />
<PackageReference Include="LtxConfigModel" />
paket add LtxConfigModel --version 1.0.0
#r "nuget: LtxConfigModel, 1.0.0"
#:package LtxConfigModel@1.0.0
#addin nuget:?package=LtxConfigModel&version=1.0.0
#tool nuget:?package=LtxConfigModel&version=1.0.0
LtxConfigModel
A small .NET library for parsing, representing and serializing .ltx configuration files used by the S.T.A.L.K.E.R. series.
Features
- Parse .ltx text into a document model composed of sections and lines
- Preserve padding, comments and include directives
- Modify keys, values and sections programmatically and serialize back to text
Quick Start
Installation
This project targets .NET 6, .NET 8, and .NET 10. Reference the NuGet package or add the project to your solution.
Basic Usage
using LtxConfigModel;
var content = @"
[general]
fullscreen = true ; enable fullscreen
[render]
texture_detail = 2, 4, 6
";
// Parse
var parser = new LtxParser(content);
var doc = parser.Parse();
// Access sections
var render = doc.FindSection("render");
var keys = render?.GetKeys();
var textureValues = render?.GetValues("texture_detail");
// Modify a value
render?.SetValue("texture_detail", "3");
// Add new section and key
var sec = doc.AddSection("custom");
sec.AddKeyValue("enabled", "1");
// Serialize back to text
var output = doc.Serialize();
Console.WriteLine(output);
Working with Lines and Elements
The model exposes a Line class that contains a sequence of LineElement objects. Elements include:
- KeyElement — the left-hand key of a key/value line
- ValueElement — the value block (can contain multiple ValueItem tokens)
- CommentElement — trailing comment starting with
; - IncludeElement —
#include "path"directive
You can create lines programmatically using factory helpers:
var line = Line.KeyValue("my_key", "my_value");
var lineWithComment = Line.KeyValueComment("my_key", "my_value", "a note");
var include = Line.Include("configs\\other.ltx");
API Overview
LtxDocument
Represents the entire parsed .ltx file:
Root— the root (unnamed) sectionSections— all sections in the documentAddSection(name)— add a new sectionFindSection(name)— find a section by name (case-insensitive)Serialize()— convert back to text
LtxSection
Represents a named section [name:parent1, parent2]:
Name— section nameLines— list of lines in the sectionAdd(line)— add a line to the sectionAddKeyValue(key, value)— shortcut to add a key/value pairGetKeys()— return all keys in the sectionGetValue(key)— get single value for a keyGetValues(key)— get all comma-separated values for a keySetValue(key, value)— replace a valueSetValues(key, values)— replace multiple values
Line
Represents a single line of configuration:
KeyValue(key, value)— factory for key/value linesKeyValueComment(key, value, comment)— factory with trailing commentInclude(path)— factory for include directivesComment(text)— factory for comment-only linesEmpty()— factory for empty linesAdd(element)— add an element to the lineGetKey()— get the KeyElement if presentGetValue()— get the ValueElement if presentGetValues()— get value items if presentSerialize()— convert back to text
Preserving Formatting
The library tries to preserve padding and comments when parsing and re-serializing. Use Padding values on elements when building lines manually to control spacing exactly.
var padding = new Padding(left: 2, right: 1); // 2 spaces left, 1 space right
var key = new KeyElement("my_key", padding);
Notes
This library focuses on faithful round-trip parsing and editing of .ltx files rather than interpreting semantics. It preserves whitespace, comments, and include directives, allowing safe programmatic editing of keys, values, and sections.
License
MIT
| 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 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 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
- No dependencies.
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
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.0.0 | 133 | 6/26/2026 |