gmaps-api-net icon indicating copy to clipboard operation
gmaps-api-net copied to clipboard

Better api for Dependency Injection

Open avin-kavish opened this issue 6 years ago • 0 comments

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>();

avin-kavish avatar Jun 06 '19 11:06 avin-kavish