Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

The example in the settings documentation for the contents of a .ini file is given as: 

[section1]

setting1=value1

 

Which is accessed as "/section1/setting1". But how are nested settings specified in the .ini? For example if I want to access

"/section1/setting1/nested section/setting2"

 

 

 

i think nesting of sections is not allowed by INI standards.
 
http://en.wikipedia.org/wiki/INI_file - Sections
Properties may be grouped into arbitrarily named sections. The section name appears on a line by itself, in square brackets ([ and ]). All properties after the section declaration are associated with that section. There is no explicit "end of section" delimiter; sections end at the next section declaration, or the end of the file. Sections may not be nested.

So a file like below should be accessed as "/nestedSection/setting2".
[section1]
setting1=value1
[nestedSection]
setting2=value2

i think nesting of sections is not allowed by INI standards.
 
http://en.wikipedia.org/wiki/INI_file - Sections
Properties may be grouped into arbitrarily named sections. The section name appears on a line by itself, in square brackets ([ and ]). All properties after the section declaration are associated with that section. There is no explicit "end of section" delimiter; sections end at the next section declaration, or the end of the file. Sections may not be nested.

So a file like below should be accessed as "/nestedSection/setting2".
[section1]
setting1=value1
[nestedSection]
setting2=value2

In normal INI file, nested sections are not allowed. But using Cinchoo framework, it can achieved as below
 
For a sample INI file below (C:\Temp\NestedIniSection.ini)
 
[CORPORATIONS]

[CORPORATIONS/FINANCE]
CORP1=JP Morgan Chase
COPR2=Morgan Stantly

[CORPORATIONS/TECHNOLOGY]
CORP1=Google
COPR2=Apple
Nested ini sections are given using '/' seperators. ‘CORPORATIONS’ section contains ‘FINANCE’ and ‘TECHNOLOGY’ subsections. There are couple ways, we can access them programmatically
using (ChoIniDocument iniDocument = ChoIniDocument.Load(@"C:\Temp\NestedIniSection.ini"))
{
Console.WriteLine(iniDocument["CORPORATIONS/TECHNOLOGY"]["CORP1"]);
Console.WriteLine(iniDocument["CORPORATIONS"].GetSection("TECHNOLOGY")["CORP1"]);
For more information, please visit http://www.cinchoo.com

In normal INI file, nested sections are not allowed. But using Cinchoo framework, it can achieved as below
 
For a sample INI file below (C:\Temp\NestedIniSection.ini)
 
[CORPORATIONS]

[CORPORATIONS/FINANCE]
CORP1=JP Morgan Chase
COPR2=Morgan Stantly

[CORPORATIONS/TECHNOLOGY]
CORP1=Google
COPR2=Apple
Nested ini sections are given using '/' seperators. ‘CORPORATIONS’ section contains ‘FINANCE’ and ‘TECHNOLOGY’ subsections. There are couple ways, we can access them programmatically
using (ChoIniDocument iniDocument = ChoIniDocument.Load(@"C:\Temp\NestedIniSection.ini"))
{
Console.WriteLine(iniDocument["CORPORATIONS/TECHNOLOGY"]["CORP1"]);
Console.WriteLine(iniDocument["CORPORATIONS"].GetSection("TECHNOLOGY")["CORP1"]);
For more information, please visit http://www.cinchoo.com