googleads / google-ads-dotnet

This project hosts the .NET client library for the Google Ads API.
https://developers.google.com/google-ads/api
Apache License 2.0
71 stars 95 forks source link

Add GoogleAdsClient to DI container #540

Closed jeffdahl closed 1 week ago

jeffdahl commented 10 months ago

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

Raibaz commented 1 month ago

Hi @jeffdahl, thanks for looking into this and sending the PR out, and sorry for the late review!

I'd like to merge this: would you be able to rebase your branch on top of the current main?

Raibaz commented 1 week ago

This was implemented in #573