-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
ff3fc53
commit c74b0aa
Showing
5 changed files
with
132 additions
and
198 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
sample/src/NimblePros.SampleToDo.Core/CoreServiceExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using NimblePros.SampleToDo.Core.Interfaces; | ||
using NimblePros.SampleToDo.Core.Services; | ||
|
||
namespace NimblePros.SampleToDo.Core; | ||
|
||
public static class CoreServiceExtensions | ||
{ | ||
public static IServiceCollection AddCoreServices(this IServiceCollection services, ILogger logger) | ||
{ | ||
services.AddScoped<IToDoItemSearchService, ToDoItemSearchService>(); | ||
services.AddScoped<IDeleteContributorService, DeleteContributorService>(); | ||
|
||
logger.LogInformation("{Project} services registered", "Core"); | ||
|
||
return services; | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
sample/src/NimblePros.SampleToDo.Core/DefaultCoreModule.cs
This file was deleted.
Oops, something went wrong.
153 changes: 0 additions & 153 deletions
153
sample/src/NimblePros.SampleToDo.Infrastructure/AutofacInfrastructureModule.cs
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
sample/src/NimblePros.SampleToDo.Infrastructure/InfrastructureServiceExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using Ardalis.SharedKernel; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using NimblePros.SampleToDo.Core.Interfaces; | ||
using NimblePros.SampleToDo.Infrastructure.Data; | ||
using NimblePros.SampleToDo.Infrastructure.Data.Queries; | ||
using NimblePros.SampleToDo.Infrastructure.Email; | ||
using NimblePros.SampleToDo.UseCases.Contributors.List; | ||
using NimblePros.SampleToDo.UseCases.Projects.ListIncompleteItems; | ||
using NimblePros.SampleToDo.UseCases.Projects.ListShallow; | ||
|
||
namespace NimblePros.SampleToDo.Infrastructure; | ||
|
||
public static class InfrastructureServiceExtensions | ||
{ | ||
public static IServiceCollection AddInfrastructureServices( | ||
this IServiceCollection services, | ||
ILogger logger, | ||
bool isDevelopment) | ||
{ | ||
if (isDevelopment) | ||
{ | ||
RegisterDevelopmentOnlyDependencies(services); | ||
} | ||
else | ||
{ | ||
RegisterProductionOnlyDependencies(services); | ||
} | ||
|
||
RegisterEF(services); | ||
|
||
logger.LogInformation("{Project} services registered", "Infrastructure"); | ||
|
||
return services; | ||
} | ||
|
||
private static void RegisterDevelopmentOnlyDependencies(IServiceCollection services) | ||
{ | ||
services.AddScoped<IEmailSender, SmtpEmailSender>(); | ||
services.AddScoped<IListContributorsQueryService, FakeListContributorsQueryService>(); | ||
services.AddScoped<IListIncompleteItemsQueryService, FakeListIncompleteItemsQueryService>(); | ||
services.AddScoped<IListProjectsShallowQueryService, FakeListProjectsShallowQueryService>(); | ||
} | ||
|
||
private static void RegisterProductionOnlyDependencies(IServiceCollection services) | ||
{ | ||
services.AddScoped<IEmailSender, SmtpEmailSender>(); | ||
services.AddScoped<IListContributorsQueryService, ListContributorsQueryService>(); | ||
services.AddScoped<IListIncompleteItemsQueryService, ListIncompleteItemsQueryService>(); | ||
services.AddScoped<IListProjectsShallowQueryService, ListProjectsShallowQueryService>(); | ||
} | ||
|
||
private static void RegisterEF(IServiceCollection services) | ||
{ | ||
services.AddScoped(typeof(IRepository<>), typeof(EfRepository<>)); | ||
services.AddScoped(typeof(IReadRepository<>), typeof(EfRepository<>)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters