Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persisting configuration items in .net

I have a set of configuration items I need to persist to a "human readable" file. These items are in a hierarchy:

Device 1
   Name
   Channel 1
     Name
     Size
     ...
   Channel N
     Name
...
Device M
   Name
   Channel 1

Each of these item could be stored in a Dictionary with a string Key and a value. They could also be in a structure/DTO.

I don't care about the format of the file as long as it's human readable. It could be XML or it could have something more like INI format

[Header]
  Key=value
  Key2=value
...

Is there a way to minimize the amount of boiler plate code I would need to write to manage storing/reading configuration items?

Should I just create Data Transfer Objects (DTO)/structures and mark them serializable (Does that generate bloated XML still human readable?)

Is there other suggestions?

Edit: Not that the software has to write as well as read the config. That leaves app.config out.

like image 719
Benoit Avatar asked Nov 17 '25 21:11

Benoit


1 Answers

YAML for .NET

like image 117
Mark Cidade Avatar answered Nov 20 '25 12:11

Mark Cidade



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!