google-ads-dotnet icon indicating copy to clipboard operation
google-ads-dotnet copied to clipboard

Add GoogleAdsClient to DI container

Open jeffdahl opened this issue 1 year ago • 0 comments

With minimal impact to the Google.Ads.GoogleAds.Core project (only adding two interfaces), this PR introduces the Google.Ads.GoogleAds.Extensions.DependencyInjection project. This new project can be packaged independently providing flexibility to include it only when needed. If using dependency injection, GoogleAds can now be configured and injected into the DI container with one line:

services.AddGoogleAdsClient(Configuration);

Once called, the DI container has a configured IGoogleAdsClient that can be injected like any other dependency.

The test project, Google.Ads.GoogleAds.Extensions.DependencyInjection.Tests, shows this in action.

Closes #483

jeffdahl avatar Oct 24 '23 16:10 jeffdahl