1

N00b here. I've been looking around for a bit on how I might accomplish this but have not had much luck, and am hoping for some code examples.

I am using a plugin architecture that is working pretty well. It "discovers" other assemblies (web projects) and then compiles them into the current website's "Areas". Here is the code I am using (for reference) Click Here.

For some of these plugins I am faced with a choice: I have 3 services that would use a plugin, but are unique in some way as to not make the plugin totally reusable. I could just create 3 spearate plugins and pull them into the 3 different main web apps. But then I thought to create an Area within the plugin and got it to work (in that the extra Area is picked up and put into the main website (so Area > Area). I felt the latter approach would work so I created 3 areas within the plugin, with common code being in the main part of the plugin, and each 3 areas having code/views specific to the 3 services.

Now, where I am stumped is in figuring out how I might be able determine which of the 3 services' areas to use when a user is on one of 3 separate websites I have. I can create 3 separate Main apps and pull in the plugins no problem. Each of the 3 websites will have it's own Database, so I started to think that if there was some way to determine which DBContext is being used from the main site then I could determine which of the 3 areas to use within the plugin.

I thought maybe that the main controller of the plugin could have some if/else logic, or some other class file in the root of the plugin could handle that. This is where I need help. Any examples would be much appreciated.

EDIT: Going to try and show the folder structure:

-Plugin1
    -...
    -Areas
        -One
            -Controllers, Views, etc.
        -Two
            -Controllers, Views, etc.
        -Three
            -Controllers, Views, etc.
    -Controllers
    -Views
         -...
-Website1
    -...
    -Areas 
        -Plugin1 <- hidden files in VS2010, created by plugin architecture
            -Areas (from Plugin1)
                -One
                -Two
                -Three
            -Views (from root of Plugin1)
    -Controllers, Views, etc.
4

0 回答 0