Skip to content

Commit

Permalink
Service & DbContext dependency injection in LumenModuleBase
Browse files Browse the repository at this point in the history
  • Loading branch information
Elanis committed Dec 29, 2024
1 parent a6b864b commit c8ccf72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Lumen.Modules.Sdk/Lumen.Modules.Sdk.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
Expand All @@ -24,6 +24,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
</ItemGroup>
</Project>
12 changes: 7 additions & 5 deletions Lumen.Modules.Sdk/LumenModuleBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace Lumen.Modules.Sdk {
public abstract class LumenModuleBase {
Expand Down Expand Up @@ -29,9 +30,10 @@ public bool IsWorkerModule() {
// Scheduled events
public abstract bool ShouldRunNow(LumenModuleRunsOnFlag currentEnv);

// Database-related methods
public abstract bool IsUsingDatabase(LumenModuleRunsOnFlag currentEnv);
public abstract Type GetModuleDatabaseContext();
public abstract string GetModuleDatabaseContextSchemaName();
// Setup DI/DBContext/...
public static void SetupServicesAsync(LumenModuleRunsOnFlag currentEnv, IServiceCollection serviceCollection, string? postgresConnectionString) {

Check warning on line 34 in Lumen.Modules.Sdk/LumenModuleBase.cs

View workflow job for this annotation

GitHub Actions / build

Remove the 'Async' suffix to the name of this method. (https://rules.sonarsource.com/csharp/RSPEC-4261)

Check warning on line 34 in Lumen.Modules.Sdk/LumenModuleBase.cs

View workflow job for this annotation

GitHub Actions / build

Remove the 'Async' suffix to the name of this method. (https://rules.sonarsource.com/csharp/RSPEC-4261)
throw new NotImplementedException();

Check warning on line 35 in Lumen.Modules.Sdk/LumenModuleBase.cs

View workflow job for this annotation

GitHub Actions / build

Implement this method or throw 'NotSupportedException' instead. (https://rules.sonarsource.com/csharp/RSPEC-3717)

Check warning on line 35 in Lumen.Modules.Sdk/LumenModuleBase.cs

View workflow job for this annotation

GitHub Actions / build

Implement this method or throw 'NotSupportedException' instead. (https://rules.sonarsource.com/csharp/RSPEC-3717)
}
public abstract Type GetDatabaseContextType();

Check warning on line 37 in Lumen.Modules.Sdk/LumenModuleBase.cs

View workflow job for this annotation

GitHub Actions / build

Consider making method 'GetDatabaseContextType' a property. (https://rules.sonarsource.com/csharp/RSPEC-4049)

Check warning on line 37 in Lumen.Modules.Sdk/LumenModuleBase.cs

View workflow job for this annotation

GitHub Actions / build

Consider making method 'GetDatabaseContextType' a property. (https://rules.sonarsource.com/csharp/RSPEC-4049)
}
}

0 comments on commit c8ccf72

Please sign in to comment.