ericnewton76 / gmaps-api-net

C# google maps api interface for interacting with the backend web services for Google Maps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Better api for Dependency Injection

avin-kavish opened this issue · comments

commented

Along with the interface extraction going on for v2, I think it would be a good idea to expose an ASP NET friendly service registration API that fits in to the existing Service Configuration paradigm.

A similar monolithic API with multiple sub-services is AWS. AWS has a separate DI package that adds the following (and other) extension methods to the Microsoft.Extensions.DependencyInjection namespace

  services.AddDefaultAWSOptions(awsOptions);
  services.AddAWSService<IAmazonS3>();

A similar setup would make this library more practical and easier to use in ASP NET (Core) applications

services.AddDefaultGMapsOptions(/* API key etc */);
services.Configure<DefaultGMapsOptions>(options => {
  options.ApiKey = 'blah blah';
  options.Timeout = TimeSpan.FromSeconds(5);
  /* etc */
});
services.AddGMapsService<IGMapsGeocoding>();