1
0
mirror of synced 2024-11-25 04:03:09 +01:00
Tapeti/Tapeti.Flow.SQL/ConfigExtensions.cs
Mark van Renswoude 6c32665c8a [ci skip] Refactored how consume result is handled
Reimplemented the exception strategy and logging
Much XML documentation, such wow
2019-08-14 12:20:53 +02:00

52 lines
1.5 KiB
C#

using System.Collections.Generic;
using Tapeti.Config;
// ReSharper disable UnusedMember.Global
namespace Tapeti.Flow.SQL
{
/// <summary>
/// Extends ITapetiConfigBuilder to enable Flow SQL.
/// </summary>
public static class ConfigExtensions
{
/// <summary>
/// Enables the Flow SQL repository.
/// </summary>
/// <param name="config"></param>
/// <param name="connectionString"></param>
/// <param name="tableName"></param>
public static ITapetiConfigBuilder WithFlowSqlRepository(this ITapetiConfigBuilder config, string connectionString, string tableName = "Flow")
{
config.Use(new FlowSqlRepositoryExtension(connectionString, tableName));
return config;
}
}
internal class FlowSqlRepositoryExtension : ITapetiExtension
{
private readonly string connectionString;
private readonly string tableName;
public FlowSqlRepositoryExtension(string connectionString, string tableName)
{
this.connectionString = connectionString;
this.tableName = tableName;
}
public void RegisterDefaults(IDependencyContainer container)
{
container.RegisterDefaultSingleton<IFlowRepository>(() => new SqlConnectionFlowRepository(connectionString, tableName));
}
public IEnumerable<object> GetMiddleware(IDependencyResolver dependencyResolver)
{
return null;
}
}
}