f1ana / Nominatim.API

Library for utilizing geocoding (forward and reverse), in addition to address lookups, with the Nominatim HTTP API. Targets .NET 6 and .NET Standard 2.0.
https://www.nuget.org/packages/Nominatim.API
MIT License
50 stars 27 forks source link

Dependency Injection #37

Open m1dst opened 5 months ago

m1dst commented 5 months ago

I can't seem to work out the DI requirements for v2 of this library. I've registered it how I think but the app crashes when I try to get an instance. All my other DI stuff works, but this fails. Could you perhaps provide a sample?

This is how I registered them.

builder.Services.AddScoped<INominatimWebInterface, NominatimWebInterface>();
builder.Services.AddScoped<IAddressSearcher, AddressSearcher>();
builder.Services.AddScoped<IForwardGeocoder, ForwardGeocoder>();
builder.Services.AddScoped<IReverseGeocoder, ReverseGeocoder>();
EwoutdBoer commented 1 month ago

There is an example in the Integration test project: https://github.com/f1ana/Nominatim.API/blob/master/src/Nominatim.API.Tests.Integration/AddressLookupTests.cs