Skip to content

Custom Simplify.Web bootstrapper

Alexanderius edited this page Jul 3, 2025 · 3 revisions

Custom Simplify.Web bootstrapper

Each Simplify.Web framework class is replaceable. You can create your implementation of any class and use it instead. To do that, create a class in your web-site assembly derived from BaseBootstrapper and then use the provided methods to register your implementation.

Basic types registration

Some Simplify.Web classes are registered by default using the general register method of the IOC container without custom creation. For those classes, you can simply set a type.

For example, if you want to use your custom page generator as a decorator to the existing generator

First, create your class which you want to use

public class MyPageGenerator(IPageGenerator baseGenerator) : IPageGenerator
{
    public string Generate(IDataCollector dataCollector)
    {
        var result = baseGenerator.Generate(dataCollector);

        // Your custom code

        return result;
    }
}

Then, create your custom bootstrapper and set the page processor type in the constructor

public class MyBootstrapper : BaseBootstrapper
{
    public override void RegisterPageGenerator()
    {
        BootstrapperFactory.ContainerProvider.Register<PageGenerator>();
        BootstrapperFactory.ContainerProvider.Register<IPageGenerator>(r => new MyPageGenerator(r.Resolve<PageGenerator>()));
    }
}
  • The MyBootstrapper class will be loaded by the framework automatically when the framework starts.

Another way of overriding internal type registrations

You can override an internal type by using the RegisterSimplifyWeb override parameter:

.RegisterSimplifyWeb(registrationsOverride: x =>
{
    x.OverridePageGenerator(r =>
    {
        r.Register<PageGenerator>();
        r.Register<IPageGenerator>(r => new MyPageGenerator(r.Resolve<PageGenerator>()));
    });
})

<< Previous page Next page >>

Clone this wiki locally