1
0
mirror of synced 2024-11-16 06:43:51 +00:00
Tapeti/Tapeti.Flow/FlowExtension.cs

38 lines
1.2 KiB
C#

using System.Collections.Generic;
using Tapeti.Config;
using Tapeti.Flow.Default;
namespace Tapeti.Flow
{
/// <inheritdoc />
/// <summary>
/// Provides the Flow middleware.
/// </summary>
public class FlowExtension : ITapetiExtension
{
private readonly IFlowRepository flowRepository;
/// <inheritdoc />
public FlowExtension(IFlowRepository flowRepository)
{
this.flowRepository = flowRepository;
}
/// <inheritdoc />
public void RegisterDefaults(IDependencyContainer container)
{
container.RegisterDefault<IFlowProvider, FlowProvider>();
container.RegisterDefault<IFlowStarter, FlowStarter>();
container.RegisterDefault<IFlowHandler, FlowProvider>();
container.RegisterDefaultSingleton(() => flowRepository ?? new NonPersistentFlowRepository());
container.RegisterDefaultSingleton<IFlowStore, FlowStore>();
}
/// <inheritdoc />
public IEnumerable<object> GetMiddleware(IDependencyResolver dependencyResolver)
{
yield return new FlowBindingMiddleware();
}
}
}