-
-
Notifications
You must be signed in to change notification settings - Fork 9
Custom Simplify.Web bootstrapper
Alexanderius edited this page Jun 6, 2024
·
2 revisions
Each Simplify.Web framework class is replaceable, you can create your implementation of any class and use it instead of, to do that, you should create a class in your web-site assembly derived from BaseBootstrapper
and then use provided methods to register your implementation.
Some Simplify.Web classes by default registered using general register method of IOC container without custom creation. For that classes your can just simply set a type.
public class MyPageGenerator(IPageGenerator baseGenerator) : IPageGenerator
{
public string Generate(IDataCollector dataCollector)
{
var result = baseGenerator.Generate(dataCollector);
// Your custom code
return result;
}
}
public class MyBootstrapper : BaseBootstrapper
{
public override void RegisterPageGenerator()
{
BootstrapperFactory.ContainerProvider.Register<PageGenerator>();
BootstrapperFactory.ContainerProvider.Register<IPageGenerator>(r => new MyPageGenerator(r.Resolve<PageGenerator>));
}
}
-
MyBootstrapper
class will be loaded by framework automatically when framework starts.
You can override an internal type by using RegisterSimplifyWeb
override parameter:
.RegisterSimplifyWeb(registrationsOverride: x =>
{
x.OverridePageGenerator(r =>
{
r.Register<PageGenerator>();
r.Register<IPageGenerator>(r => new MyPageGenerator(r.Resolve<PageGenerator>));
});
})
- Getting Started
- Main Simplify.Web principles
- Simplify.Web controllers
- Simplify.Web views
- Simplify.Web templates
- Simplify.Web configuration
- Templates variables
- Static content
- Template factory
- Data collector
- String table
- File reader
- Web context
- Environment
- Dynamic environment
- Language manager
- Redirector
- HTML