IniGetter 1.0.3
dotnet add package IniGetter --version 1.0.3
NuGet\Install-Package IniGetter -Version 1.0.3
<PackageReference Include="IniGetter" Version="1.0.3" />
<PackageVersion Include="IniGetter" Version="1.0.3" />
<PackageReference Include="IniGetter" />
paket add IniGetter --version 1.0.3
#r "nuget: IniGetter, 1.0.3"
#:package IniGetter@1.0.3
#addin nuget:?package=IniGetter&version=1.0.3
#tool nuget:?package=IniGetter&version=1.0.3
IniGetter
Ini File Handler for .NET Standard and .NET Framework
Let's take a minute to configure the simple configuration file. It's been around in many forms over the past 60 or 70 years, the first files were probably simple lines of text, each line representing something special... but proprietary formats have to be documented, and suffer over time; they also are more inflexible and resist program enhancements. Pure binary configuration files are worse, requiring special programs to update, or components written to handle their creation. Eventually, programs began using simple key/value pairs and parsed the values. This allowed for human editable files and generic, reusable code could be created to provide access to these formats. As we entered the "Age of Microsoft" we saw the prototypical INI file format start to take shape. Key/value pairs could be broken into sections, and comments could be included in the file, to make human editing of the file easier and self-documented. The INI file has persisted from MS-DOS and lasted into the current age of operating systems, though it is, by all measures, very obsolete - replaced by JSON (and before that, XML) formats which are able to take complex data objects and serialize/deserialize them with ease.
Today, the INI file is mostly relegated to legacy systems; I'd recommend using JSON for any new projects, as it is relatively trivial to load and save in this format today. In some applications, INI files are written out by the application at runtime ("preferences"). Many enhancements to the INI file format were done to accommodate more complex data structures, often at the expense of human readability and editability.
IniGetter is a library intended to standardize access to this format and provide a robust interface to minimize potential issues and increase performance. Optionally, it can provide the ability to watch for changed files, values, and even write values back out.
The basic format of an ini file is as follows:
# Comments can begin with a pound sign
; ...or a semi-colon. Neither of these characters can be used in a section or key name
# Global section is simply an unnamed section that begins the ini file. These values will live in section ""
global=globalvalue
# Section names can be alpha-numeric and may include spaces " ", underscores "_", dashes "-", exclamation points "!", at symbols "@", percent symbols "%", carats "^", periods ".", ampersands "&" and dollar signs "$"
# Section and keynames will always be trimmed for whitespace at beginning and end
[section]
# Key names can include everything a section can.
# values include everything after the equal sign, trimmed - unless quoted, in which case, the contents of the quotes are completely included
# there can only be one unique key name per section. The last entry with a redundant key will "win" - warnings will be generated by the parser
# values requiring "escaped" characters MUST be quoted
key=value
longer key with space = some other value
# data types
# IniGetter will attempt to parse a value to whatever format you want, but boolean values are more robust.
# Boolean can evaluate 0 or 1 (or any non-zero value), yes or no, on or off, true or false
IsSomething=true
IsAnotherThing=0
IsNotAnything=no
Using IniGetter:
IniFile iniMySettings = new IniFile("C:\\Data\\MyIniFile.ini");
string someValue = iniMySettings.Get("TheSection", "TheKey", "a default value");
bool someBoolean = iniMySettings.Get("TheSection", "TheBooleanKey", false);
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 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 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net35 is compatible. net40 is compatible. net403 was computed. net45 is compatible. net451 is compatible. net452 was computed. net46 is compatible. net461 is compatible. 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. |
-
.NETCoreApp 3.1
- Newtonsoft.Json (>= 13.0.3)
-
.NETFramework 3.5
- Newtonsoft.Json (>= 13.0.3)
-
.NETFramework 4.0
- Newtonsoft.Json (>= 13.0.3)
-
.NETFramework 4.5
- Newtonsoft.Json (>= 13.0.3)
- System.Text.RegularExpressions (>= 4.3.1)
-
.NETFramework 4.5.1
- Newtonsoft.Json (>= 13.0.3)
- System.Text.RegularExpressions (>= 4.3.1)
-
.NETFramework 4.6
- Newtonsoft.Json (>= 13.0.3)
- System.Text.RegularExpressions (>= 4.3.1)
-
.NETFramework 4.6.1
- Newtonsoft.Json (>= 13.0.3)
- System.Text.RegularExpressions (>= 4.3.1)
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.3)
- System.Text.RegularExpressions (>= 4.3.1)
-
.NETStandard 2.1
- Newtonsoft.Json (>= 13.0.3)
- System.Text.RegularExpressions (>= 4.3.1)
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Set up Multi-target in project file