2017-02-07 17:22:28 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Tapeti.Config;
|
|
|
|
|
|
|
|
|
|
namespace Tapeti.Flow.SQL
|
|
|
|
|
{
|
|
|
|
|
public static class ConfigExtensions
|
|
|
|
|
{
|
2017-02-08 14:52:24 +00:00
|
|
|
|
public static TapetiConfig WithFlowSqlRepository(this TapetiConfig config, string connectionString, int serviceId, string schema = "dbo")
|
2017-02-07 17:22:28 +00:00
|
|
|
|
{
|
2017-02-08 14:52:24 +00:00
|
|
|
|
config.Use(new FlowSqlRepositoryBundle(connectionString, serviceId, schema));
|
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;
|
|
|
|
|
private readonly string schema;
|
|
|
|
|
private readonly int serviceId;
|
2017-02-07 17:22:28 +00:00
|
|
|
|
|
2017-02-08 14:52:24 +00:00
|
|
|
|
|
|
|
|
|
public FlowSqlRepositoryBundle(string connectionString, int serviceId, string schema)
|
|
|
|
|
{
|
|
|
|
|
this.connectionString = connectionString;
|
|
|
|
|
this.serviceId = serviceId;
|
|
|
|
|
this.schema = schema;
|
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)
|
|
|
|
|
{
|
2017-02-08 14:52:24 +00:00
|
|
|
|
container.RegisterDefault<IFlowRepository>(() => new SqlConnectionFlowRepository(connectionString, serviceId, schema));
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|