Refactor infrastructure service setup
Renamed `AddInfrastructureServices` to `AddRecInfrastructure` in both generic and non-generic forms to standardize naming and improve clarity. Updated `Program.cs` to use the new method, adding database context configuration with a connection string from the app's configuration. Added a constraint to `AddRecInfrastructure<TRecDbContext>` requiring `TRecDbContext` to inherit from `RecDbContext`. Refactored the method to register entities from the assembly containing `RecAction`. Removed the old `AddInfrastructureServices` method entirely.
This commit is contained in:
parent
89879d0821
commit
5ba012cc13
@ -10,7 +10,7 @@ builder.Services.AddRecServices(options =>
|
|||||||
options.LuckyPennySoftwareLicenseKey = builder.Configuration["LuckyPennySoftwareLicenseKey"];
|
options.LuckyPennySoftwareLicenseKey = builder.Configuration["LuckyPennySoftwareLicenseKey"];
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddInfrastructureServices(options =>
|
builder.Services.AddRecInfrastructure(options =>
|
||||||
{
|
{
|
||||||
options.ConfigureDbContext((dbContextOpt) =>
|
options.ConfigureDbContext((dbContextOpt) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -7,7 +7,7 @@ namespace ReC.Infrastructure;
|
|||||||
|
|
||||||
public static class DependencyInjection
|
public static class DependencyInjection
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddInfrastructureServices<TRecDbContext>(this IServiceCollection services, Action<ConfigurationOptions> options)
|
public static IServiceCollection AddRecInfrastructure<TRecDbContext>(this IServiceCollection services, Action<ConfigurationOptions> options)
|
||||||
where TRecDbContext : RecDbContext
|
where TRecDbContext : RecDbContext
|
||||||
{
|
{
|
||||||
var configOpt = new ConfigurationOptions();
|
var configOpt = new ConfigurationOptions();
|
||||||
@ -23,8 +23,8 @@ public static class DependencyInjection
|
|||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IServiceCollection AddInfrastructureServices(this IServiceCollection services, Action<ConfigurationOptions> options)
|
public static IServiceCollection AddRecInfrastructure(this IServiceCollection services, Action<ConfigurationOptions> options)
|
||||||
=> services.AddInfrastructureServices<RecDbContext>(options);
|
=> services.AddRecInfrastructure<RecDbContext>(options);
|
||||||
|
|
||||||
public class ConfigurationOptions
|
public class ConfigurationOptions
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user