SharpConfig icon indicating copy to clipboard operation
SharpConfig copied to clipboard

Multiline Support for Arrays Keys

Open jvilomar opened this issue 4 years ago • 2 comments

Hi, thanks for this wonderful tool.

I am trying to get an array key spanned to multiple lines.

Like this:

[Sources]
Files = {
   "....File1.txt",
   "....File2.txt",
   "....File3.txt"}

But I am getting a Setting Assignment Parse Exception. I have to do this in multi-lines because I need to parse multiple files and making the user place all files on a single line could be a little weird.

Any thoughts on this?

Thanks in advance.

jvilomar avatar Mar 23 '21 13:03 jvilomar

Hi Jose, there already is a plan to improve the parser in this regard. If you need a workaround for now, I suggest you read your configuration file in as a string. Then, search for the start and end position of the {"File1", "File2", ...} portion and replace the newlines within this portion, thus creating a string that is parsable for SharpConfig. You can then load the configuration using Configuration.LoadFromString() and passing that string.

Since there are other issues open right now, I think it's time so release a new version in the upcoming days/weeks.

Let me know if that helped, cheers.

cemdervis avatar Mar 23 '21 16:03 cemdervis

Hi Cem, thanks for the response and the tip.

I will be trying that and I will let you know how it went.

Thanks.

jvilomar avatar Mar 24 '21 11:03 jvilomar