I currently have a plugin system developed using ASP.NET and MVC. Plugins are stored in their own folders within a Plugins folder in the main "Core" site. Within each Plugin is a folder for any related Views, content, etc. The structure looks like this. (Some other folders/files omitted)
+ /
| + bin/
| + Controllers/
| + Plugins/
| | + PluginA/
| | | + bin/
| | | + Content/
| | | + Views/
| | + PluginB/
| | | + bin/
| | | + Content/
| | | + Views/
| + Views/
| Global.asax
What I would like to be able to do is use virtual paths within the plugin views, that resolve relative to the Plugin directory. Eg, ~/Content/image.png in PluginA would be resolved to /Plugins/PluginA/Content/image.png.
A translation to the expected virtual path (~/Plugins/PluginA/Content/image.png) is also acceptable, and would actually be preferred.
Given that the folder name of each plugin is an unknown until runtime, and which plugins, if any, are present is also unknown until runtime, is this possible?
So far it seems like I should use a custom VirtualPathProvider, but I am unsure as to how to get which plugin is calling this.
Another option is to expose a wrapper method for virtual paths the plugin has to explicitly call that would translate it into a core-relative virtual path. Something like..
Plugin.Virtual("~/Content/image.png"); // returns "~/Plugins/PluginA/Content/image.png"
Would this be a better option?
Aucun commentaire:
Enregistrer un commentaire