Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cl/service registration methods #43

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Dfe.Data.SearchPrototype/Dfe.Data.SearchPrototype.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
<None Remove="Web\**" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="Common\Dfe.Data.SearchPrototype.Common.csproj" />
</ItemGroup>
Expand Down
35 changes: 35 additions & 0 deletions Dfe.Data.SearchPrototype/Infrastructure/DependencyRegistration.cs
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>();
}
}

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>();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace Dfe.Data.SearchPrototype.SearchForEstablishments.Models;

/// <summary>
/// Encapsulates the address details of an Establishment
/// </summary>
public class Address
{
/// <summary>
Expand Down