Created
May 26, 2021 21:52
-
-
Save MelbourneDeveloper/7b4d9d69b230828fc35599dfca29c680 to your computer and use it in GitHub Desktop.
ASP .NET Core Dependency Injection (RestClient.Net)
This file contains hidden or 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
| var serviceCollection = new ServiceCollection() | |
| //Add a service which has an IClient dependency | |
| .AddSingleton<IGetString, GetString1>() | |
| //Add RestClient.Net with a default Base Url of http://www.test.com | |
| .AddRestClient((o) => o.BaseUrl = "http://www.test.com".ToAbsoluteUrl()); | |
| //Use HttpClient dependency injection | |
| _ = serviceCollection.AddHttpClient(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment