Library implemented in .NET using C# that helps developers to deserialize or serialize INI files and strings. It is compatible with a large range of .NET framework versions, from desktop, to mobile and servers.
This library can be installed via NuGet package. Just run the following command:
Install-Package SimpleSoft.IniParser -PreThe most recent version is in Release Candidate 1. It is considered very stable, just missing some extension methods to make it simpler to manage IniContainer, IniSection or IniProperties instances and compatibility with older PCL.
This library is compatible with the folowing frameworks:
- .NET Framework 4.5
- .NET Core 5.0;
- .NET Standard 1.0;
usingSystem;usingMicrosoft.Extensions.Logging;usingSimpleSoft.IniParser.Impl;namespaceSimpleSoft.IniParser.Examples{publicclassBasicExample:IExample{privatereadonlyILogger<BasicExample>_logger;publicBasicExample(ILogger<BasicExample>logger){_logger=logger;}publicvoidRun(){conststringinitialIni=@";This is a commentSomeGP=This is a global property[SomeSection];This is a comment inside a sectionSomeSP=This is a property inside a section[AnotherSection];Another comment...AnotherSP=More?Response=YES!!!";_logger.LogInformation("Initial INI string: '{initialIniString}'",initialIni);_logger.LogDebug("Deserializing string as an IniContainer...");vardeserializer=newIniDeserializer{Options={NormalizeAfterDeserialization=false}};variniContainer=deserializer.DeserializeAsContainer(initialIni);_logger.LogDebug("Normalizing IniContainer...");varnormalizer=newIniNormalizer();iniContainer=normalizer.Normalize(iniContainer);_logger.LogDebug("Serializing IniContainer as a string...");varserializer=newIniSerializer{Options={EmptyLineBeforeSection=true,NormalizeBeforeSerialization=false}};varfinalIni=serializer.SerializeAsString(iniContainer);_logger.LogInformation("Final INI string: "+Environment.NewLine+"'{finalIniString}'",finalIni);/*;This is a commentSOMEGP=This is a global property[SOMESECTION];This is a comment inside a sectionSOMESP=This is a property inside a section[ANOTHERSECTION];Another comment...ANOTHERSP=More?RESPONSE=YES!!! */}}}usingSystem;usingMicrosoft.Extensions.Logging;usingSimpleSoft.IniParser.Impl;namespaceSimpleSoft.IniParser.Examples{publicclassDefaultGlobalInstanceExample:IExample{privatereadonlyILogger<DefaultGlobalInstanceExample>_logger;publicDefaultGlobalInstanceExample(ILogger<DefaultGlobalInstanceExample>logger){_logger=logger;}publicvoidRun(){conststringinitialIni=@";This is a commentSomeGP=This is a global property[SomeSection];This is a comment inside a sectionSomeSP=This is a property inside a section[AnotherSection];Another comment...AnotherSP=More?Response=YES!!!";_logger.LogInformation("Initial INI string: '{initialIniString}'",initialIni);_logger.LogDebug("Deserializing string as an IniContainer...");variniContainer=IniDeserializer.Default.DeserializeAsContainer(initialIni);_logger.LogDebug("Normalizing IniContainer...");iniContainer=IniNormalizer.Default.Normalize(iniContainer);_logger.LogDebug("Serializing IniContainer as a string...");varfinalIni=IniSerializer.Default.SerializeAsString(iniContainer);_logger.LogInformation("Final INI string: "+Environment.NewLine+"'{finalIniString}'",finalIni);/*;This is a commentSOMEGP=This is a global property[SOMESECTION];This is a comment inside a sectionSOMESP=This is a property inside a section[ANOTHERSECTION];Another comment...ANOTHERSP=More?RESPONSE=YES!!! */}}}