开发者

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

开发者 https://www.devze.com 2022-12-21 02:14 出处:网络
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. I

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.


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.


Your request for the functionality is quite a peculiar one. Usually the framework (or some special library) doesn't know about the application's design and requirements, neither does it know when is it an appropriate moment to ask something from the user. Moreover, usually the plugins are loaded on demand, not at the application start, so having any UI logic here triggered by the framework/library may be highly inappropriate.

So, basically it looks like you'll need to write the library yourself.

0

精彩评论

暂无评论...
验证码 换一张
取 消