Skip to content

Instantly share code, notes, and snippets.

@MelbourneDeveloper
Created May 26, 2021 21:52
Show Gist options
  • Select an option

  • Save MelbourneDeveloper/7b4d9d69b230828fc35599dfca29c680 to your computer and use it in GitHub Desktop.

Select an option

Save MelbourneDeveloper/7b4d9d69b230828fc35599dfca29c680 to your computer and use it in GitHub Desktop.
ASP .NET Core Dependency Injection (RestClient.Net)
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