Plugin to use its own app.config

前端 未结 6 1328
星月不相逢
星月不相逢 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:00

    I usually prefer to avoid the whole app.config mess by creating a dedicated Xml file that the host processes with the plugin's settings also inside. The Xml would look something like this:

    
        
            Here's where anything specific to the app goes.
        
        
            
                Here I let the plugin serialize itself however it wants to.
            
        
    
    

    The hosting app then creates the plugin from the type attribute and tests if the class implements ISerializable; if it does, then the plugin will deserialize itself. It's a bit scary to have the plugins inline with the app's settings, but if you load the plugin's substring of Xml into a new XmlReader then you don't have to worry about an error in the plugin from reading too far in the Xml string.

提交回复
热议问题