有没有类似“选项”的东西? .NET 的库?
我正在开发一个插件系统。有些插件需要用户输入。我希望他们能够向主应用程序报告他们需要什么输入,并让主应用程序决定如何获取它。似乎可能有某种库是为指定这样的选项而设计的。因此,插件可以返回某种指定选项名称和类型的选项对象,主应用程序可以使用这些选项来确定显示哪种类型的控件来获取所需的选项。
我不知道是否存在这样的东西,但考虑到似乎有很多应用程序使用这样的选项,这似乎有点可能。我正在考虑像 Firefox 的 about:config 这样的东西,它只显示大量选项列表并知道如何处理每个选项。基本上我希望能够为我的主应用程序创建一个 about:config 页面(它不是网络应用程序或浏览器,这只是一个示例),该页面可以查看插件想要的选项并自动生成一个简单的界面(例如 about:config )来获取这些选项。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果它是 WinForms 应用程序,请查看 PropertyGrid控制。您创建一个类对象,其中包含您希望用户配置的所有选项的属性。然后使用该对象设置 PropertyGrid 的“SelectedObject”属性。然后,该控件将创建一个窗口,让您的用户在运行时修改选项对象的值。
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.
您对功能的要求非常奇特。通常框架(或一些特殊的库)不知道应用程序的设计和需求,也不知道什么时候是向用户询问某些内容的合适时机。此外,通常插件是按需加载的,而不是在应用程序启动时加载,因此由框架/库触发的任何 UI 逻辑可能非常不合适。
所以,基本上看起来您需要自己编写该库。
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.