1
0
mirror of synced 2024-11-24 01:33:50 +00:00
Tapeti/Tapeti.Flow.SQL/ConfigExtensions.cs

43 lines
1.1 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using Tapeti.Config;
// ReSharper disable UnusedMember.Global
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")
{
2018-12-19 20:41:19 +00:00
config.Use(new FlowSqlRepositoryBundle(connectionString, tableName));
return config;
}
}
internal class FlowSqlRepositoryBundle : ITapetiExtension
{
private readonly string connectionString;
2018-12-19 20:41:19 +00:00
private readonly string tableName;
2018-12-19 20:41:19 +00:00
public FlowSqlRepositoryBundle(string connectionString, string tableName)
{
this.connectionString = connectionString;
2018-12-19 20:41:19 +00:00
this.tableName = tableName;
}
public void RegisterDefaults(IDependencyContainer container)
{
2018-12-19 20:41:19 +00:00
container.RegisterDefaultSingleton<IFlowRepository>(() => new SqlConnectionFlowRepository(connectionString, tableName));
}
public IEnumerable<object> GetMiddleware(IDependencyResolver dependencyResolver)
{
return null;
}
}
}