Last active
March 16, 2020 21:18
-
-
Save ankitvijay/287c2a8bc484205ec6e44ab2d27e43b5 to your computer and use it in GitHub Desktop.
Captive Dependecy 5 - Typed HttpClient example 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddControllers(); | |
services.AddSingleton<SingletonService>(); | |
services.AddHttpClient<CatalogClient>(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SingletonService | |
{ | |
// Warning: This is crime!!! - DO NOT DO THIS | |
public SingletonService(CatalogClient catalogClient) | |
{ | |
this.catalogClient = catalogClient; | |
} | |
public async Task<List<string>> GetCatalogs() | |
{ | |
return await catalogClient.GetCatalogs(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment