1
0
mirror of synced 2024-11-25 04:03:09 +01:00

Flow repository kan worden meegegeven bij de WithFlow() configuratie

This commit is contained in:
Menno van Lavieren 2017-07-27 17:30:36 +02:00
parent 8d069e1c48
commit c79d7eec4f
2 changed files with 10 additions and 3 deletions

View File

@ -2,9 +2,9 @@
{ {
public static class ConfigExtensions public static class ConfigExtensions
{ {
public static TapetiConfig WithFlow(this TapetiConfig config) public static TapetiConfig WithFlow(this TapetiConfig config, IFlowRepository<Default.FlowState> flowRepository)
{ {
config.Use(new FlowMiddleware()); config.Use(new FlowMiddleware(flowRepository));
return config; return config;
} }
} }

View File

@ -6,12 +6,19 @@ namespace Tapeti.Flow
{ {
public class FlowMiddleware : ITapetiExtension public class FlowMiddleware : ITapetiExtension
{ {
private IFlowRepository<Default.FlowState> flowRepository;
public FlowMiddleware(IFlowRepository<Default.FlowState> flowRepository)
{
this.flowRepository = flowRepository;
}
public void RegisterDefaults(IDependencyContainer container) public void RegisterDefaults(IDependencyContainer container)
{ {
container.RegisterDefault<IFlowProvider, FlowProvider>(); container.RegisterDefault<IFlowProvider, FlowProvider>();
container.RegisterDefault<IFlowStarter, FlowStarter>(); container.RegisterDefault<IFlowStarter, FlowStarter>();
container.RegisterDefault<IFlowHandler, FlowProvider>(); container.RegisterDefault<IFlowHandler, FlowProvider>();
container.RegisterDefault<IFlowRepository<FlowState>, NonPersistentFlowRepository<FlowState>>(); container.RegisterDefault<IFlowRepository<FlowState>>(() => flowRepository ?? new NonPersistentFlowRepository<Default.FlowState>());
container.RegisterDefault<IFlowStore, FlowStore>(); container.RegisterDefault<IFlowStore, FlowStore>();
} }