Plugin to use its own app.config

前端 未结 6 1310
星月不相逢
星月不相逢 2021-02-19 21:22

I finally managed to build a working solution of a plugin architecture with help of some guys over here, but now a new problem arises.

My hosting application uses it\'s

6条回答
  •  忘掉有多难
    2021-02-19 22:08

    I prefer to build and use an IConfigManager type plugin. It job is to abstract how the configuration is stored. You receive an instance of it through dependency injection. This way, the IConfigManager implementation can load settings from multiple .config files, from the network, a db or any other source. I also use it to provide default values based on user, machine and/or application - which can be overridden by the user e.g. background colour, font etc.

    Other advantages to this method are that settings can be persisted in a consistent way across all plugins - without the plugins having to care, the place where your plugin stores its settings can change transparently (from .config to other) and lastly, the IConfigManager can be mocked during unit testing to simulate different situations.

    I hope that helps.

提交回复
热议问题