44 lines
1.6 KiB
C#
44 lines
1.6 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Svrnty.GeoManagement.Abstractions.Abstractions;
|
|
using Svrnty.GeoManagement.Google.Configuration;
|
|
|
|
namespace Svrnty.GeoManagement.Google.Extensions;
|
|
|
|
/// <summary>
|
|
/// Extension methods for registering Google Geocoding services
|
|
/// </summary>
|
|
public static class ServiceCollectionExtensions
|
|
{
|
|
/// <summary>
|
|
/// Adds Google Geocoding provider to the service collection
|
|
/// </summary>
|
|
/// <param name="services">The service collection</param>
|
|
/// <param name="configuration">Configuration section containing GoogleGeoManagementOptions</param>
|
|
/// <returns>The service collection for chaining</returns>
|
|
public static IServiceCollection AddGoogleGeoManagement(
|
|
this IServiceCollection services,
|
|
IConfiguration configuration)
|
|
{
|
|
services.Configure<GoogleGeoManagementOptions>(configuration);
|
|
services.AddScoped<IGeoManagementProvider, GeoManagementGoogleProvider>();
|
|
|
|
return services;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds Google Geocoding provider to the service collection with manual configuration
|
|
/// </summary>
|
|
/// <param name="services">The service collection</param>
|
|
/// <param name="configureOptions">Action to configure GoogleGeoManagementOptions</param>
|
|
/// <returns>The service collection for chaining</returns>
|
|
public static IServiceCollection AddGoogleGeoManagement(
|
|
this IServiceCollection services,
|
|
Action<GoogleGeoManagementOptions> configureOptions)
|
|
{
|
|
services.Configure(configureOptions);
|
|
services.AddScoped<IGeoManagementProvider, GeoManagementGoogleProvider>();
|
|
|
|
return services;
|
|
}
|
|
} |