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
|
|
|
|
|
{
|
|
|
|
|
public static class ConfigExtensions
|
|
|
|
|
{
|
2018-12-19 20:41:19 +00:00
|
|
|
|
public static TapetiConfig WithFlowSqlRepository(this TapetiConfig config, string connectionString, string tableName = "Flow")
|
2017-02-07 17:22:28 +00:00
|
|
|
|
{
|
2018-12-19 20:41:19 +00:00
|
|
|
|
config.Use(new FlowSqlRepositoryBundle(connectionString, tableName));
|
2017-02-07 17:22:28 +00:00
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal class FlowSqlRepositoryBundle : ITapetiExtension
|
|
|
|
|
{
|
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
|
|
|
|
|
2018-12-19 20:41:19 +00:00
|
|
|
|
public FlowSqlRepositoryBundle(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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|