-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cl/service registration methods (#43)
* add extension methods to register dependencies
- Loading branch information
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
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
35 changes: 35 additions & 0 deletions
35
Dfe.Data.SearchPrototype/Infrastructure/DependencyRegistration.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,35 @@ | ||
using Azure.Search.Documents.Models; | ||
using Azure; | ||
using Dfe.Data.SearchPrototype.Common.Mappers; | ||
using Dfe.Data.SearchPrototype.Infrastructure.Mappers; | ||
using Dfe.Data.SearchPrototype.SearchForEstablishments; | ||
using Dfe.Data.SearchPrototype.SearchForEstablishments.Models; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Azure.Search.Documents; | ||
using Dfe.Data.SearchPrototype.Infrastructure.Options.Mappers; | ||
using Dfe.Data.SearchPrototype.Infrastructure.Options; | ||
|
||
namespace Dfe.Data.SearchPrototype.Infrastructure; | ||
|
||
/// <summary> | ||
/// Extension method which provides all the pre-registrations required to | ||
/// access services to adapt the Dfe.Data.Common.Infrastructure.CognitiveSearch infrastructure | ||
/// to SearchPrototype application layer | ||
/// </summary> | ||
public static class DependencyRegistration | ||
{ | ||
/// <summary> | ||
/// Register the necessary infrastucture adaptor services | ||
/// </summary> | ||
/// <param name="services"></param> | ||
public static void AddCognitiveSearchAdaptorServices(this IServiceCollection services) | ||
{ | ||
services.AddScoped(typeof(ISearchServiceAdapter), typeof(CognitiveSearchServiceAdapter<Establishment>)); | ||
services.AddSingleton(typeof(IMapper<Pageable<SearchResult<Establishment>>, EstablishmentResults>), typeof(PageableSearchResultsToEstablishmentResultsMapper)); | ||
services.AddSingleton<IMapper<SearchSettingsOptions, SearchOptions>, SearchOptionsToAzureOptionsMapper>(); | ||
services.AddSingleton<IMapper<Establishment, Address>, AzureSearchResultToAddressMapper>(); | ||
services.AddSingleton<IMapper<Establishment, SearchForEstablishments.Models.Establishment>, AzureSearchResultToEstablishmentMapper>(); | ||
services.AddScoped<ISearchOptionsFactory, SearchOptionsFactory>(); | ||
} | ||
} | ||
|
20 changes: 20 additions & 0 deletions
20
Dfe.Data.SearchPrototype/SearchForEstablishments/DependencyRegistration.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,20 @@ | ||
using Dfe.Data.SearchPrototype.Common.CleanArchitecture.Application.UseCase; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Dfe.Data.SearchPrototype.SearchForEstablishments; | ||
|
||
/// <summary> | ||
/// Extension method which provides all the pre-registrations required to | ||
/// use the SearchForEstablishments services | ||
/// </summary> | ||
public static class DependencyRegistration | ||
{ | ||
/// <summary> | ||
/// Register all the necessary SearchForEstablishments services | ||
/// </summary> | ||
/// <param name="services"></param> | ||
public static void AddSearchForEstablishmentServices(this IServiceCollection services) | ||
{ | ||
services.AddScoped<IUseCase<SearchByKeywordRequest, SearchByKeywordResponse>, SearchByKeywordUseCase>(); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Dfe.Data.SearchPrototype/SearchForEstablishments/Models/Address.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