Initializing the EV5 ViewEngine

In the Startup class you can add the ViewEngine to the list of used MVC ViewEngines via the following line:

services.AddRazorPages()
    .AddViewOptions(o => o.ViewEngines.Insert(0new EmbeddedViewEngine("eve-")));
Here we are suing the AddViewOptions extensionmethod of the IMvcBuilder interface. Note, that you can specify the place of the ViewEngine. It's order will determine the order in which the MVC engine will look for the view names in the engines. So, if you are using EV5 ViewEngine primarily, you can specify that to be the first. Also note, that you can specify a prefix for the registered EV5 ViewEngine. The EV5 ViewEngine will only process views with a name starting with this prefix. This way you can register multiple EV5 viewengines, and direct specific views to specific engines.

Adding Default EV5 services

The EV5 ViewEngine is using the following services:

  • IViewClassProvider: to find the view classes for a given view. Default: MEFViewClassProvider
  • IMarkupProvider: to find the html code for a given view. Default: EmbeddedMarkupProvider
  • IDocumentHelperFactory: help access the html from the ViewClass. Default: HADocumentHelperFactory
Using the AddEV5DefaultServices extension of IServiceCollection will add the default services. In addition it will also register the API utility services. Use it like this in you Startup class in the ConfigureServices method:
//this call sets up the default EV5 Services
services.AddEV5DefaultServices();

Auto Discovering and registering the web parts of plugins

Use the UseEmbeddedPlugins extension of the IServiceCollection in the ConfigureServices method to auto discover the plugins. You have to specify the ICompositionHostFactory that is responsible to find all the IEmbeddedPlugin implementations. By default use the DirCompositionHostFactory class to specify a directory and a search pattern to consider all relevant assemblies.

//This method will discover all exported IEmbeddedPlugins in the provided CompositionHostFactory
           //It will then use the information in these objects to set up the web components and.
           services.UseEmbeddedPlugins(new DirCompositionHostFactory(AppDomain.CurrentDomain.BaseDirectory, "EV5*.dll"));

Prepare File Providers for using the plugins

Use the ConfigureEmbeddedPlugins extension of the IWebHostEnvironment in the Configure method to auto discover the plugins and prepare the environemnt to use CompositeFileProvider containing the FileProviders of the plugins.

env.ConfigureEmbeddedPlugins();
You can use this version of the configure method to access the IWebHostEnvironment:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)