Creating modules

Veva is designed to be highly modular and to fulfill that design goal, it includes a powerful module loading system. Developers can easily extend the system by writing custom modules.

Veva is designed to be highly modular and to fulfill that design goal, it includes a powerful module loading system. Developers can easily extend the system by writing custom modules.

What is a module in Veva?

A module is basically a class which implements the IModule interface in Veva. A single Module in Veva can contain a variety of things, like custom components, custom themes and various other custom extensions which the core system supports.

A custom module is usually a separate VS project, with a Module.cs class which implements the IModule interface in Veva. Upon startup, Veva automatically locates and instantiates classes which implement this interface and calls various methods which are defined in the interface.

All modules are required to have public properties for name and priority which enables developers to control in what order the modules are loaded up, if required.

public string Name => "My Custom Module";
public int Priority => (int)ModulePriorityEnum.Default;

Required methods

These three methods are also required

void ConfigureServices(IServiceCollection services, IConfiguration configuration);

ConfigureServices() is where the module can configure it's services, like adding to the dependency injection container and so forth.

void Configure(IApplicationBuilder app, IHostEnvironment env, ILoggerFactory loggerFactory);

Configure() is where the module can access the ApplicationBuilder, Hosting environment and more to do some configuration, if needed.

void ConfigureMvc(IMvcBuilder mvc);

ConfigureMvc() is where the module can access the IMvcBuilder if the module needs to do some MVC configuration changes.

Optional methods

These methods have default bodies in the IModule interface and as such do not need to be implemented specifically.

public void ConfigureComponents(IComponentService componentService, IComponentViewService componentViewService)
{
componentService.RegisterComponent();
}

ConfigureComponents() is where the module can register any custom components which it may define.

public void InitializeDatabase(IServiceProvider serviceProvider)

InitializeDatabase() is where the module can do some database initialization, like apply pending migrations and such. Only applies if the module has it's own Database context.

public bool DatabaseMigrationsNeeded(IServiceProvider serviceProvider)
{
return false;
}

DatabaseMigrationsNeeded() allows the module to specify if it has pending migrations which need to be run. If any module which is being loaded, indicates that there are pending migrations, the Setup Wizard will be launched at startup and those pending migrations will be applied to the database.

public IEnumerable GetAppliedMigrations(IServiceProvider serviceProvider)
{
return new List();
}

GetAppliedMigrations() enables the module to list all migrations which have been applied to it's database context. This is used in the system information dialog, where the user can see a report of all applied migrations.

public void ConfigureBuilder(IWebHostBuilder builder)

ConfigureBuilder() enables the module access the WebHostBuilder to make any required configuration changes there.