This repository has been archived by the owner on Jun 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Custom Simplify.Web bootstrapper
Alexanderius edited this page Jun 30, 2019
·
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 MyPageProcessor : IPageProcessor
{
private readonly PageProcessor _pp;
public MyPageProcessor(IPageBuilder pageBuilder, IResponseWriter responseWriter, IRedirector redirector)
{
_pp = new PageProcessor(pageBuilder, responseWriter, redirector);
}
public Task ProcessPage(IDIContainerProvider containerProvider, IOwinContext context)
{
// some custom code
return _pp.ProcessPage(containerProvider, context);
}
}
public class MyBootstrapper : BaseBootstrapper
{
public MyBootstrapper()
{
// Setting type of your page processor
SetPageProcessorType<MyPageProcessor>();
}
}
-
MyBootstrapper
class will be loaded by framework automatically when framework starts.
Some Simplify.Web types created only by register delegate of IOC container, for example, Environment
:
public virtual void RegisterEnvironment()
{
DIContainer.Current.Register<IEnvironment>(
p => new Environment(AppDomain.CurrentDomain.BaseDirectory, p.Resolve<ISimplifyWebSettings>()));
}
For such king of classes you should override respective Register method (you can do the same for basic Simplify.Web types also).
Your custom Environment
:
public class MyEnvironment : IEnvironment
{
public MyEnvironment()
{
}
...
}
public class MyBootstrapper : BaseBootstrapper
{
public override void RegisterEnvironment()
{
DIContainer.Current.Register<IEnvironment, MyEnvironment>();
}
}
- 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
- Language manager
- Redirector
- HTML