hybridview / ConfigurationSectionDesigner

Moved from CodePlex, which is closing.,
MIT License
65 stars 19 forks source link

Using CSD to write the configuration file programmatically #15

Open danielleiszen opened 4 years ago

danielleiszen commented 4 years ago

Has anyone ever tried to save the configuration using the object model generated by this tool?

First problem: calling ConfigurationManager.GetSection as initialization, does not fill the CurrentConfiguration property, hence Save() cannot be called at all. Editing the generated file solves that problem - until next regeneration. However the base.BaseAdd() method does not seem to modify the collection. The interesting thing is base.Clear() clears the collection (in memory) but Save() does not have any effect. No exceptions, no messages, no nothing.

This whole configuration thing is simply a mess I know. And I really appreciate the effort writing a tool for this. And it works for reading, so I am wondering if anyone have tried it to use for writing?

Because I could not find any clues about how it supposed to work.

All the help is appreciated, Thanks

hybridview commented 4 years ago

At work, I wrote a full featured (and quite large) web based application that loads the configuration classes from your assembly and allows you to edit and save configuration files. It also used the validation functionality of ConfigurationManager. Unfortunately, I am not able to share. If I have time, I can write something up to help others start a similar project.

danielleiszen commented 4 years ago

I really do not need a big application since I have my infrastructure in place. I need the Save method to work during runtime and save the changes back to the config file. It shouldn't be that hard maybe I just missing some minor things.

Could you please give me an example on using CSD for the purpose?

Thank you