{"id":23711465,"url":"https://github.com/canta2899/panini","last_synced_at":"2026-04-26T16:32:38.055Z","repository":{"id":139211956,"uuid":"451114453","full_name":"canta2899/panini","owner":"canta2899","description":"A simple .NET library for INI file parsing, with a focus on chainable methods","archived":false,"fork":false,"pushed_at":"2023-07-10T09:27:59.000Z","size":310,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-30T07:47:39.689Z","etag":null,"topics":["csharp","dotnet","ini","ini-parser","panini","parsing"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/canta2899.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-23T13:36:43.000Z","updated_at":"2023-07-18T09:09:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"d6f46e2a-d406-4ee5-9932-0cd56b30db0e","html_url":"https://github.com/canta2899/panini","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/canta2899/panini","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canta2899%2Fpanini","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canta2899%2Fpanini/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canta2899%2Fpanini/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canta2899%2Fpanini/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/canta2899","download_url":"https://codeload.github.com/canta2899/panini/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canta2899%2Fpanini/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32305035,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T09:34:17.070Z","status":"ssl_error","status_checked_at":"2026-04-26T09:34:00.993Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet","ini","ini-parser","panini","parsing"],"created_at":"2024-12-30T19:49:49.314Z","updated_at":"2026-04-26T16:32:38.050Z","avatar_url":"https://github.com/canta2899.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://badges.mit-license.org)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"Panini\" src=\"./Panini/assets/panini.svg\" width=\"200\" /\u003e\n\u003c/p\u003e\n\u003ch1 align=\"center\"\u003e\n  Panini \n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  A simple .NET library for \u003cb\u003eINI\u003c/b\u003e files parsing.\n\u003c/p\u003e\n\n## Usage\n\nHere's an example on how to use **Panini** in order to create, parse and update your INIs. The main focus is on **chainable methods** and being able to build **multiple sections with the same name** (which is the main reason why i built this library).\n\n```cs\nusing System;\nusing System.Collections.Generic;\nusing Panini;\n\n// Build an IniFile istance and parse one or more files\n\nIniFile parsedIni = new IniFile();\nparsedIni.Parse(\"./test.ini\");\n\n// Extract a section and try add a new value\nparsedIni.GetSectionByName(\"General\")?.TryAdd(\"AnotherKey\", \"AnotherValue\");\n\n// Now let's try to extract a key from a section\nstring? value = parsedIni.GetSectionByName(\"General\")?.TryGet(\"AnotherKey\");\n\n// Extracts all the sections for the given name\nList\u003cIniSection\u003e sections = parsedIni.GetSectionsByName(\"User\");\n\n// Iterates through all the sections\nsections.ForEach(s =\u003e Console.WriteLine($\"Username is : {s.TryGet(\"Name\")}\"));\n\n// Adds a new section (in this case, a new user entry)\nparsedIni.AddSection(\"User\").TryAdd(\"Name\", \"Paul\")?.TryAdd(\"Surname\", \"Jacob\");\n\n// Write the changes\nparsedIni.Save(\"./newini.ini\");\n\n// Now the ini file should be updated or created at the given path\n```\n\n## How to install\n\nPanini is made of three files, so you can easily compile `/Panini/Panini.csproj` and referenced the DLL inside your project or copy the files at `/Panini/` inside your project. Otherwise you can install via [NuGet](https://www.nuget.org/packages/Panini/) by running\n\n```bash\ndotnet add package Panini --version 1.3.1\n```\n\n## API\n\nHere's a quick overview on the methods and classes that the API exposes. **Panini** aims to be a simple library so there's only a few things that you need to know before starting to use it. \n\nIni files can be handled by two objects: \n\n- `IniFile`\n- `IniSection`\n\nThe first one, in fact, wraps a collection of Ini sections and allows you to retrieve single or multiple selection or parse a new file.\n\n### Creating and parsing ini files\n\nYou can create a new IniFile object by calling\n\n```cs\nIniFile ini = new IniFile();\n```\n\nAfter that, you can parse one or multiple files by calling\n\n```cs\nini.Parse(\"path/to/your/ini\");\n```\n\n**Parsing multiple files** is also possibile by calling `Parse()` over multiple paths, the result will be a single ini construct containing the sections of all the parsed files.\n\nAn IniFile can be saved by calling\n\n```cs\nini.Save(\"path/to/your/ini\");\n```\n\nWhere you can specify a new path or the previous one (in the latter case, your ini file will be overwritten).\n\n### Retrieving sections\n\nA single section can be retrieved by calling\n\n```cs\nIniSection mySection = ini.GetSectionByName(\"name of your section\");\n```\n\nIf your IniFile object contains multiple sections with the same name, the first one will be retrieved. Moreover, **if a section with the given name does not exists**, `null` will be returned.\n\nRetrieving **multiple sections with the same name** is also possible by running\n\n```cs\nList\u003cIniSection\u003e mySections = ini.GetSectionsByName(\"name of your sections\");\n```\n\nIn this case, a list of IniSections will be returned (the list will be empty if no section with the given name is found).\n\n**All** the sections can be obtained by running\n\n```cs\nList\u003cIniSection\u003e allTheSections = ini.GetAllSections();\n```\n\n### Adding or removing a new section\n\nA new section requires to be\n\n1. Created\n2. Added to the ini file\n\nYou can create a new section by running\n\n```cs\nIniSection newSection = ini.AddSection(\"name of the new section\");\n```\n\nor by instanciating it through the constructor\n\n```cs\nIniSection newSection = new IniSection(\"name of the new section\");\nini.AddSection(newSection);\n```\n\nA sections can also be removed from the file by running\n\n```cs\nini.RemoveSectionByName(\"name of the section to be removed\");\n```\n\n### Retrieving, removing and adding entries \n\nA new key-value entry can be added to a section by running\n\n```cs\nmySection.TryAdd(\"Key\", \"Value\");\n```\n\nwhich returns `null` if the pair couldn't be added to the file (this mainly happens because a key with the same name already exists).\n\nIn order to remove a key and its value you can instead run\n\n```cs\nmySection.TryRemove(\"Key\");\n```\n\nYou can also use the **Set** option in order to add or replace a value by running\n\n```cs\nmySection.Set(\"key\", \"value\");\n```\n\nIn this case, if the key exists its value will be replaced. Otherwise, the method behaves like the `TryAdd` option.\n\n### Adding comments\n\nLines starting with `#` will be parsed as comments and added to the **Comments** property of a section. You can also add new comments in code by running \n\n```cs\nmySection.AddComment(\"my new line of comment\");\n```\n\n### Clearing all the sections\n\nAll the sections can be cleared from a file by running \n\n```cs\nini.Clear();\n```\n\nRemember that, in order be applied to the `.ini` file, these modifications require you to call the `Save()` method too.\n\n### Chaining methods\n\nYou can use the previous methods in a **chained fashion** like the following example:\n\n```cs\n// Creating the ini \nIniFile ini = new IniFile();\n\n// Parsing two files\nini.Parse(\"./myini1.ini\");\nini.Parse(\"./myini2.ini\");\n\n// Chaining methods\n\nini.GetSectionByName(\"section1\")?.Set(\"key\", \"value\");\n\nini.GetSectionsByName(\"multiple\").ForEach(x =\u003e Console.WriteLine(s.TryGet(\"key\")));\n\nini.AddSection(\"newSection\").Set(\"key\", \"value\").Set(\"key2\", \"value2\");\n\nini.Save(\"./newpath.ini\");\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanta2899%2Fpanini","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcanta2899%2Fpanini","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanta2899%2Fpanini/lists"}