2017-02-07 17:22:28 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Tapeti.Config;
|
|
|
|
|
|
2018-12-19 19:50:56 +00:00
|
|
|
|
// ReSharper disable UnusedMember.Global
|
|
|
|
|
|
2017-02-07 17:22:28 +00:00
|
|
|
|
namespace Tapeti.Flow.SQL
|
|
|
|
|
{
|
2019-08-14 10:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Extends ITapetiConfigBuilder to enable Flow SQL.
|
|
|
|
|
/// </summary>
|
2017-02-07 17:22:28 +00:00
|
|
|
|
public static class ConfigExtensions
|
|
|
|
|
{
|
2019-08-14 10:20:53 +00:00
|
|
|
|
/// <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")
|
2017-02-07 17:22:28 +00:00
|
|
|
|
{
|
2019-08-14 10:20:53 +00:00
|
|
|
|
config.Use(new FlowSqlRepositoryExtension(connectionString, tableName));
|
2017-02-07 17:22:28 +00:00
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-08-14 10:20:53 +00:00
|
|
|
|
internal class FlowSqlRepositoryExtension : ITapetiExtension
|
2017-02-07 17:22:28 +00:00
|
|
|
|
{
|
2017-02-08 14:52:24 +00:00
|
|
|
|
private readonly string connectionString;
|
2018-12-19 20:41:19 +00:00
|
|
|
|
private readonly string tableName;
|
2017-02-07 17:22:28 +00:00
|
|
|
|
|
2017-02-08 14:52:24 +00:00
|
|
|
|
|
2019-08-14 10:20:53 +00:00
|
|
|
|
public FlowSqlRepositoryExtension(string connectionString, string tableName)
|
2017-02-08 14:52:24 +00:00
|
|
|
|
{
|
|
|
|
|
this.connectionString = connectionString;
|
2018-12-19 20:41:19 +00:00
|
|
|
|
this.tableName = tableName;
|
2017-02-07 17:22:28 +00:00
|
|
|
|
}
|
2017-02-08 14:52:24 +00:00
|
|
|
|
|
2017-02-07 17:22:28 +00:00
|
|
|
|
|
|
|
|
|
public void RegisterDefaults(IDependencyContainer container)
|
|
|
|
|
{
|
2018-12-19 20:41:19 +00:00
|
|
|
|
container.RegisterDefaultSingleton<IFlowRepository>(() => new SqlConnectionFlowRepository(connectionString, tableName));
|
2017-02-07 17:22:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-08 14:52:24 +00:00
|
|
|
|
|
2017-02-07 17:22:28 +00:00
|
|
|
|
public IEnumerable<object> GetMiddleware(IDependencyResolver dependencyResolver)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|