Skip to content

Commit

Permalink
✨ Add config to configure services
Browse files Browse the repository at this point in the history
  • Loading branch information
Hona committed Mar 20, 2024
1 parent 228f4c4 commit 680dbd5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public interface IFeature
{
static abstract void ConfigureServices(IServiceCollection services);
static abstract void ConfigureServices(IServiceCollection services, IConfiguration config);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public sealed class TodoFeature : IFeature
{
public static void ConfigureServices(IServiceCollection services)
public static void ConfigureServices(IServiceCollection services, IConfiguration config)
{

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public static class FeatureDiscovery
{
private static readonly Type ModuleType = typeof(IFeature);

public static void ConfigureFeatures(this IServiceCollection services, params Assembly[] assemblies)
public static void ConfigureFeatures(this IServiceCollection services, IConfiguration config, params Assembly[] assemblies)
{
if (assemblies.Length == 0)
{
Expand All @@ -18,7 +18,7 @@ public static void ConfigureFeatures(this IServiceCollection services, params As
foreach (var type in moduleTypes)
{
var method = GetConfigureServicesMethod(type);
method?.Invoke(null, [services]);
method?.Invoke(null, [services, config]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/VerticalSliceArchitectureTemplate/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

builder.Services.AddExceptionHandler<ExceptionHandler.KnownExceptionsHandler>();

builder.Services.ConfigureFeatures(appAssembly);
builder.Services.ConfigureFeatures(builder.Configuration, appAssembly);

var app = builder.Build();

Expand Down

0 comments on commit 680dbd5

Please sign in to comment.