Search code examples
.netpluginsconfigurationpreferences

Is there something like an "Options" library for .NET?


I'm working on a plugin system. Some plugins need user input. I would like them to be able to report to the main application what input they need and have the main application decide how to get it. It seems like there might be some kind of library designed for specifying options like this. So like the plugin could return some kind of Options object specifying names and types of options which the main application could use to determine what kind of controls to show to get the needed options.

I have no idea if something like this exists, but it seems somewhat likely given that there seem to be a lot of applications to use options like this. I'm thinking of things like Firefox's about:config that just shows a massive list of options and knows how to handle each one. Basically I want to be able to make an about:config page for my main application (it's not a web app or a browser, that's just an example) that sees what options the plugins want and automatically generates a simple interface (like about:config) to get those options.


Solution

  • If it's a WinForms app, take a look at the PropertyGrid control. You create a class object that contains properties for all of the options you want the user to configure. Then you set the "SelectedObject" property of your PropertyGrid with this object. The control will then create a window that lets your user modify the values of your options object at runtime.