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

Simple INI parser and writer.
Getting started
Use global using
directive for the whole project:
global using Functional;
global using Configuration;
global using static Functional.Prelude;
global using static Configuration.Prelude;
Or using
directive in the single file:
using Functional;
using Configuration;
using static Functional.Prelude;
using static Configuration.Prelude;
Initial Configuration.ini content:
[section_one]
# Comment
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
Call Ini
function. Pass the IEqualityComparer<string>
that will be used to determine equality of keys in the configuration:
Result<Ini, string> result = Ini(new FileInfo("Configuration.ini"));
Result<Ini, string> result = Ini(new FileInfo("Configuration.ini"), StringComparer.OrdinalIgnoreCase);
Use Match()
function to extract the configuration:
Ini ini = result.Match(ini => ini, err => throw new ApplicationException(err));
Use Item[section]
property to get a section:
Option<Section> one = ini["section_one"];
Option<Section> four = ini["section_four"];
bool oneIsSome = one.IsSome;
bool fourIsNone = four.IsNone;
Assert.True(oneIsSome);
Assert.True(fourIsNone);
Use Item[section, key]
property to get a value:
Option<string> oneOne = ini["section_one", "KeyOne"];
Option<string> twoTwo = ini["section_two", "KeyTwo"];
Option<string> threeThree = ini["section_three", "KeyThree"];
Assert.Equal("Some(SectionOne_ValueOne)", oneOne.ToString());
Assert.Equal("Some(SectionTwo_ValueTwo)", twoTwo.ToString());
Assert.Equal("None", threeThree.ToString());
Use IsSome
and IsNone
properties to check, if the value exists:
bool oneOneIsSome = oneOne.IsSome;
bool threeThreeIsSome = threeThree.IsSome;
bool threeThreeIsNone = threeThree.IsNone;
Assert.True(oneOneIsSome);
Assert.False(threeThreeIsSome);
Assert.True(threeThreeIsNone);
Call Match()
function to extract the value, if exists:
string oneOneValue = oneOne.Match(some => some, "none");
string threeThreeValue = threeThree.Match(some => some, "none");
Assert.Equal("SectionOne_ValueOne", oneOneValue);
Assert.Equal("none", threeThreeValue);
Set Some(value)
to change the value:
ini["section_one", "KeyOne"] = Some("SectionOne_ValueOne_Changed");
Option<string> oneOneChanged = ini["section_one", "KeyOne"];
string oneOneChangedValue = oneOneChanged.Match(some => some, "none");
Assert.Equal("SectionOne_ValueOne_Changed", oneOneChangedValue);
Set Some(value)
to add new value:
ini["section_one", "KeyThree"] = Some("SectionOne_ValueThree_Added");
Option<string> oneThreeAdded = ini["section_one", "KeyThree"];
string oneThreeAddedValue = oneThreeAdded.Match(some => some, "none");
Assert.Equal("SectionOne_ValueThree_Added", oneThreeAddedValue);
Set None
to remove the value:
ini["section_two", "KeyThree"] = None;
Option<string> twoThree = ini["section_two", "KeyThree"];
string twoThreeValue = twoThree.Match(some => some, "none");
Assert.Equal("none", twoThreeValue);
Set None
to remove the section:
ini["section_three"] = None;
Option<Section> three = ini["section_three"];
bool threeIsNone = three.IsNone;
Assert.True(threeIsNone);
Write configuration to the file:
ini.WriteTo(new FileInfo("Configuration.ini"));
Final Configuration.ini content:
[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 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 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 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. 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. |
-
.NETFramework 4.8
- Functional.Monad (>= 0.1.7)
- IndexRange (>= 1.0.3)
- IsExternalInit (>= 1.0.3)
-
.NETStandard 2.0
- Functional.Monad (>= 0.1.7)
- IndexRange (>= 1.0.3)
- IsExternalInit (>= 1.0.3)
-
net6.0
- Functional.Monad (>= 0.1.7)
-
net8.0
- Functional.Monad (>= 0.1.7)
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 |