I am trying to make a multi tenated mvc website where views can be overridden for each tenant.
I’m using RazorGenerator in order to be able to load views from a compiled assembly (with some modifications to allow multiple assemblies).
So now I need to have a way to identify Dlls in the bin that contain views. Currently I’m just creating a dummy class (Class1) and looping through AppDomain.CurrentDomain.GetAssemblies().ToList() to see what asssemblies include that dummy class
I can imagine a few possiblities.
- Create an interface
IViewPluginand assign that to myClass1in each view plugin assembly - Name each assembly
MyCompany.Presentation.Views.Plugins.[ClientName]and include all plugins that match.
Are there any other better ways to mark assemblies as being a ‘plugin’ assembly when the assemblies themself don’t have any actual classes in them (unless I specifically create one for purposes of identifying plugin assemblies)
You can create a custom attribute:
And apply it on the assembly:
You can then check if the assembly has the attribute: