-
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.
* refactor the config for application and infrastructure tiers * Tidied-up and improved comments. * Fixed broken tests. * A bit of a re-jig of the core project structure. * remove project entry for nuget generation * Correction for mapper registration in DI container * Removed package generation --------- Co-authored-by: Spencer O'HEGARTY <[email protected]>
- Loading branch information
1 parent
267915e
commit cd946a1
Showing
65 changed files
with
665 additions
and
792 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
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
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
60 changes: 60 additions & 0 deletions
60
Dfe.Data.SearchPrototype/Infrastructure/CompositionRoot.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,60 @@ | ||
using Azure; | ||
using Azure.Search.Documents.Models; | ||
using Dfe.Data.SearchPrototype.Common.Mappers; | ||
using Dfe.Data.SearchPrototype.Infrastructure.Mappers; | ||
using Dfe.Data.SearchPrototype.Infrastructure.Options; | ||
using Dfe.Data.SearchPrototype.SearchForEstablishments.ByKeyword.ServiceAdapters; | ||
using Dfe.Data.SearchPrototype.SearchForEstablishments.Models; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Dfe.Data.SearchPrototype.Infrastructure; | ||
|
||
/// <summary> | ||
/// The composition root provides a unified location in the application where the composition | ||
/// of the object graphs for the application take place, using the IOC container. | ||
/// </summary> | ||
public static class CompositionRoot | ||
{ | ||
/// <summary> | ||
/// Extension method which provides all the pre-registrations required to | ||
/// access the AI azure search service adapter, and perform searches across provisioned indexes. | ||
/// </summary> | ||
/// <param name="services"> | ||
/// The originating application services onto which to register the search dependencies. | ||
/// </param> | ||
/// <param name="configuration"> | ||
/// The originating configuration block from which to derive search service settings. | ||
/// </param> | ||
/// <exception cref="ArgumentNullException"> | ||
/// The exception thrown if no valid <see cref="IServiceCollection"/> is provisioned. | ||
/// </exception> | ||
public static void AddCognitiveSearchAdaptorServices(this IServiceCollection services, IConfiguration configuration) | ||
{ | ||
if (services is null) | ||
{ | ||
throw new ArgumentNullException(nameof(services), | ||
"A service collection is required to configure the azure AI search adapter dependencies."); | ||
} | ||
|
||
services.AddOptions<AzureSearchOptions>() | ||
.Configure<IConfiguration>( | ||
(settings, configuration) => | ||
configuration | ||
.GetSection(nameof(AzureSearchOptions)) | ||
.Bind(settings)); | ||
|
||
services.AddOptions<SearchByKeywordCriteria>() | ||
.Configure<IConfiguration>( | ||
(settings, configuration) => | ||
configuration | ||
.GetSection(nameof(SearchByKeywordCriteria)) | ||
.Bind(settings)); | ||
|
||
services.AddScoped(typeof(ISearchServiceAdapter), typeof(CognitiveSearchServiceAdapter<DataTransferObjects.Establishment>)); | ||
services.AddSingleton(typeof(IMapper<Pageable<SearchResult<DataTransferObjects.Establishment>>, EstablishmentResults>), typeof(PageableSearchResultsToEstablishmentResultsMapper)); | ||
services.AddSingleton<IMapper<Dictionary<string, IList<Azure.Search.Documents.Models.FacetResult>>, EstablishmentFacets>, AzureFacetResultToEstablishmentFacetsMapper>(); | ||
services.AddSingleton<IMapper<DataTransferObjects.Establishment, Address>, AzureSearchResultToAddressMapper>(); | ||
services.AddSingleton<IMapper<DataTransferObjects.Establishment, Establishment>, AzureSearchResultToEstablishmentMapper>(); | ||
} | ||
} |
15 changes: 12 additions & 3 deletions
15
...Prototype/Infrastructure/Establishment.cs → ...ture/DataTransferObjects/Establishment.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
35 changes: 0 additions & 35 deletions
35
Dfe.Data.SearchPrototype/Infrastructure/DependencyRegistration.cs
This file was deleted.
Oops, something went wrong.
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
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
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
Oops, something went wrong.