|
|
@@ -24,6 +24,7 @@ namespace DotNetCore.CAP |
|
|
|
services.AddScoped<ICapPublisher, CapPublisher>(); |
|
|
|
services.AddScoped<ICallbackPublisher, CapPublisher>(); |
|
|
|
services.AddTransient<IAdditionalProcessor, DefaultAdditionalProcessor>(); |
|
|
|
|
|
|
|
AddSqlServerOptions(services); |
|
|
|
} |
|
|
|
|
|
|
@@ -34,18 +35,22 @@ namespace DotNetCore.CAP |
|
|
|
_configure(sqlServerOptions); |
|
|
|
|
|
|
|
if (sqlServerOptions.DbContextType != null) |
|
|
|
{ |
|
|
|
services.AddSingleton(x => |
|
|
|
{ |
|
|
|
using (var scope = x.CreateScope()) |
|
|
|
{ |
|
|
|
var provider = scope.ServiceProvider; |
|
|
|
var dbContext = (DbContext) provider.GetService(sqlServerOptions.DbContextType); |
|
|
|
var dbContext = (DbContext)provider.GetService(sqlServerOptions.DbContextType); |
|
|
|
sqlServerOptions.ConnectionString = dbContext.Database.GetDbConnection().ConnectionString; |
|
|
|
return sqlServerOptions; |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
services.AddSingleton(sqlServerOptions); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |