Configuration.Ini
0.2.1
dotnet add package Configuration.Ini --version 0.2.1
NuGet\Install-Package Configuration.Ini -Version 0.2.1
<PackageReference Include="Configuration.Ini" Version="0.2.1" />
<PackageVersion Include="Configuration.Ini" Version="0.2.1" />
<PackageReference Include="Configuration.Ini" />
paket add Configuration.Ini --version 0.2.1
#r "nuget: Configuration.Ini, 0.2.1"
#addin nuget:?package=Configuration.Ini&version=0.2.1
#tool nuget:?package=Configuration.Ini&version=0.2.1
INI configuration file

Simple INI parser and writer.
Getting started
Initial config.ini
content:
# GlobalSection
KeyOne = GlobalSection_ValueOne
KeyTwo = GlobalSection_ValueTwo
[section_one]
KeyOne = SectionOne_ValueOne
KeyTwo = SectionOne_ValueTwo
[section_two]
KeyOne = SectionTwo_ValueOne
KeyTwo = SectionTwo_ValueTwo
KeyThree = SectionTwo_ValueThree
[section_three]
KeyOne = SectionThree_ValueOne
KeyTwo = SectionThree_ValueTwo
Import Functional
namespace:
global using Functional;
global using static Functional.Prelude;
Import Configuration
namespace:
using Configuration;
Function Ini.FromFile(path)
initializes new Ini
configuration from a file:
var ini = Ini.FromFile("config.ini").Unwrap();
Property Item[key]
gets the Option
value associated with the specified key:
var globalOne = ini["KeyOne"];
var globalTwo = ini["KeyTwo"];
var globalThree = ini["KeyThree"];
Debug.Assert(globalOne == Some("GlobalSection_ValueOne"));
Debug.Assert(globalTwo == Some("GlobalSection_ValueTwo"));
Debug.Assert(globalThree == None);
Property IsSome
returns true
if the value exists; Property IsNone
returns true
if the value doesn't exist:
Debug.Assert(globalOne.IsSome);
Debug.Assert(globalTwo.IsSome);
Debug.Assert(globalThree.IsNone);
Property Item[section, key]
gets the Option
value associated with the specified section name and key:
var oneOne = ini["section_one", "KeyOne"];
var twoTwo = ini["section_two", "KeyTwo"];
var threeThree = ini["section_three", "KeyThree"];
Debug.Assert(oneOne == Some("SectionOne_ValueOne"));
Debug.Assert(twoTwo == Some("SectionTwo_ValueTwo"));
Debug.Assert(threeThree == None);
Function Match(some, none)
safely extracts the value:
var oneOneValue = oneOne.Match(some => some, "none");
var threeThreeValue = threeThree.Match(some => some, "none");
Debug.Assert(oneOneValue == "SectionOne_ValueOne");
Debug.Assert(threeThreeValue == "none");
Set Some(value)
to change the value:
ini["section_one", "KeyOne"] = Some("SectionOne_ValueOne_Changed");
var oneOneChanged = ini["section_one", "KeyOne"];
var oneOneChangedValue = oneOneChanged.Match(some => some, "none");
Debug.Assert(oneOneChangedValue == "SectionOne_ValueOne_Changed");
Set Some(value) to add a value:
ini["section_one", "KeyThree"] = Some("SectionOne_ValueThree_Added");
var oneThreeAdded = ini["section_one", "KeyThree"];
var oneThreeAddedValue = oneThreeAdded.Match(some => some, "none");
Debug.Assert(oneThreeAddedValue == "SectionOne_ValueThree_Added");
Set None
to remove the value:
ini["section_two", "KeyThree"] = None;
var twoThree = ini["section_two", "KeyThree"];
var twoThreeValue = twoThree.Match(some => some, "none");
Debug.Assert(twoThreeValue == "none");
Function ToFile(path)
writes the Ini
configuration to a file:
ini.ToFile("config.ini");
Final config.ini
content:
KeyOne = GlobalSection_ValueOne
KeyTwo = GlobalSection_ValueTwo
[section_one]
KeyOne = SectionOne_ValueOne_Changed
KeyTwo = SectionOne_ValueTwo
KeyThree = SectionOne_ValueThree_Added
[section_two]
KeyOne = SectionTwo_ValueOne
KeyTwo = SectionTwo_ValueTwo
Sample
See GettingStarted test.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Functional.Monad (>= 0.3.0)
-
.NETStandard 2.1
- Functional.Monad (>= 0.3.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 |
---|---|---|
0.2.1 | 201 | 4/9/2025 |
0.2.0 | 163 | 4/9/2025 |
0.1.14 | 171 | 3/12/2025 |
0.1.13 | 172 | 3/11/2025 |
0.1.12 | 152 | 3/11/2025 |
0.1.11 | 158 | 3/10/2025 |
0.1.10 | 170 | 3/10/2025 |
0.1.9 | 133 | 3/9/2025 |
0.1.8 | 187 | 3/8/2025 |
0.1.7 | 213 | 3/6/2025 |
0.1.6 | 205 | 3/6/2025 |
0.1.5 | 209 | 3/5/2025 |
0.1.4 | 204 | 3/4/2025 |
0.1.3 | 200 | 3/4/2025 |
0.1.2 | 203 | 3/4/2025 |
0.1.1 | 194 | 3/3/2025 |
0.1.0 | 95 | 3/2/2025 |