StoneKit.Configuration.IniParser 2024.1.1.305385

There is a newer version of this package available.
See the version list below for details.
dotnet add package StoneKit.Configuration.IniParser --version 2024.1.1.305385                
NuGet\Install-Package StoneKit.Configuration.IniParser -Version 2024.1.1.305385                
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="StoneKit.Configuration.IniParser" Version="2024.1.1.305385" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StoneKit.Configuration.IniParser --version 2024.1.1.305385                
#r "nuget: StoneKit.Configuration.IniParser, 2024.1.1.305385"                
#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.
// Install StoneKit.Configuration.IniParser as a Cake Addin
#addin nuget:?package=StoneKit.Configuration.IniParser&version=2024.1.1.305385

// Install StoneKit.Configuration.IniParser as a Cake Tool
#tool nuget:?package=StoneKit.Configuration.IniParser&version=2024.1.1.305385                

StoneKit.Configuration.IniParser

StoneKit.Configuration.IniParser not only simplifies the parsing of INI files but also offers additional features, including the ability to read and write objects. This library is designed to make working with configuration data in INI files more versatile and convenient.

NuGet Version License

Overview

In addition to basic INI file parsing, StoneKit.Configuration.IniParser provides advanced features for handling objects. This includes reading objects from INI files and writing object properties back to INI sections. The library automatically manages the serialization and deserialization of object properties, simplifying the configuration process.

Installation

Install the library via NuGet Package Manager Console:

Install-Package StoneKit.Configuration.IniParser

Getting Started

Loading INI File

// Create an instance of IniFile and load data from the specified file
var iniFile = new IniFile();
iniFile.LoadFile("path/to/your/file.ini");

// Alternatively, use the static method to quickly load information from an INI file
var quickIniFile = IniFile.Parse("path/to/your/file.ini");

Accessing Configuration Values

// Retrieve a value from a specific section and key
string? value = iniFile["SectionName", "KeyName"];

// Retrieve a value with a default if not found
string defaultValue = iniFile["SectionName", "KeyName", "Default"];

// Get an array of section names
string[] sections = iniFile.Sections;

// Get an array of key names in a specific section
string[] keysInSection = iniFile.GetKeys("SectionName");

Reading and Writing Objects

// Define a sample configuration class
public class AppConfig
{
    public string Server { get; set; }
    public int Port { get; set; }
    public string DatabaseName { get; set; }
    // ... other properties
}

// Load an instance of AppConfig from the INI file
AppConfig config = iniFile.Load<AppConfig>("Database");

// Modify the object
config.Server = "newServer";
config.Port = 8080;

// Save the modified object back to the INI file
iniFile.Save(config);

Example INI File

; Example INI File

[Database]
Server=localhost
Port=5432
DatabaseName=mydatabase
Username=myuser
Password=mypassword

[AppSettings]
LogLevel=Info
MaxConnections=100

Contributions

Contributions, issues, and feature requests are welcome. Feel free to submit a pull request or open an issue on GitHub.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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
2024.1.1.391401 73 10/5/2024
2024.1.1.305385 63 8/5/2024
2024.1.1.268769 88 7/9/2024
2024.1.1.261674 103 7/4/2024
2024.1.1.261665 102 7/4/2024
2024.1.1.261630 100 7/4/2024
2024.1.1.260673 114 7/3/2024
2024.1.1.260489 97 7/3/2024
2024.1.1.260485 99 7/3/2024
1.24.703.180756 114 7/3/2024
1.24.703.164604 109 7/3/2024
1.24.703.121207 106 7/3/2024
1.24.626.192706 88 6/26/2024
1.24.612.859 100 6/11/2024
1.24.611.233127 96 6/11/2024
1.24.611.232750 91 6/11/2024
1.24.603.121931 77 6/3/2024
1.24.317.170730 117 3/17/2024
1.24.317.170544 97 3/17/2024
1.24.317.164648 98 3/17/2024
1.24.317.161355 89 3/17/2024
1.24.121.184215 119 1/21/2024
1.24.121.182729 106 1/21/2024