Skip to content

Commit cfcf37f

Browse files
committed
Ensure check if simple di already added
1 parent 94b5acc commit cfcf37f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

DigitalRuby.SimpleDi/DigitalRuby.SimpleDi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<IsPackable>true</IsPackable>
99
<Title>DigitalRuby.SimpleDi</Title>
1010
<Description>Simple, declarative dependency injection and configuration using attributes - without all the boilerplate code.</Description>
11-
<Version>1.0.7</Version>
11+
<Version>1.0.8</Version>
1212
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
1313
<Company>Digital Ruby, LLC</Company>
1414
<Copyright>(c) 2022-Present Digital Ruby, LLC</Copyright>

DigitalRuby.SimpleDi/ServicesHelper.cs renamed to DigitalRuby.SimpleDi/ServicesExtensions.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <summary>
44
/// Dependency injection helper for services
55
/// </summary>
6-
public static class ServicesHelper
6+
public static class ServicesExtensions
77
{
88
/// <summary>
99
/// Ensures that we don't double-call any UseSimpleDi types
@@ -19,7 +19,7 @@ private class BindingAttributeClearService : BackgroundService
1919
protected override Task ExecuteAsync(CancellationToken stoppingToken)
2020
{
2121
BindingAttribute.Clear();
22-
ServicesHelper.typesCalledInUseSimpleDi.Clear();
22+
ServicesExtensions.typesCalledInUseSimpleDi.Clear();
2323
return Task.CompletedTask;
2424
}
2525
}
@@ -37,6 +37,11 @@ protected override Task ExecuteAsync(CancellationToken stoppingToken)
3737
/// <param name="namespaceFilterRegex"></param>
3838
public static void AddSimpleDi(this IServiceCollection services, IConfiguration configuration, string? namespaceFilterRegex = null)
3939
{
40+
if (services.SimpleDiAdded())
41+
{
42+
return;
43+
}
44+
4045
BindBindingAttributes(services, namespaceFilterRegex);
4146

4247
// this will clear the binding attribute cache and then immediately terminate, removing itself from the list of hosted services

0 commit comments

Comments
 (0)