Dependency Injection
The Argent Pony Warcraft Client includes tools to make registering the various interfaces with the IServiceCollection in .NET Core applications a snap!
Make sure you have installed the ArgentPoneyWarcraftClient.Extensions.DependencyInjection NuGet package as described in Getting Started.
Register services#
To start off, add the appropriate using statement to the file.
Then use the AddWarcraftClients() method on the IServiceCollection instance. For example, in ASP.NET Core applications this would be in the ConfigureServices() method like so.
Similar to directly instantiating the WarcraftClient, you also have the option to specify the locale and region you want to use.
Once the services are registered with the container you can list them as dependencies for your controllers or services.
In addition to registering the IWarcraftClient, it registers all of the discrete interfaces as well, such as the IProfileApi or IAchievementApi. This allows your component to depend only on the specific APIs you need.