public static IRestOptionsBuilder AddRestClient(this IServiceCollection services, string baseUrl = null) { IRestOptionsBuilder builder = new RestOptionsBuilder(services); builder.Services.AddScoped(typeof(RestOptions <>), typeof(DefaultRestOptions <>)); builder.Services.AddScoped(typeof(RestClient <>)); builder.Services.AddScoped <RestOptions>(); builder.Services.AddSingleton <IContentFormatter, JsonContentFormatter>(sp => new JsonContentFormatter(CreateDefaultJsonSettings())); builder.Services.AddScoped <DefaultFormatterSelector>(sp => () => "application/json"); if (!string.IsNullOrWhiteSpace(baseUrl)) { builder = builder.WithBaseUrl(baseUrl); } return(builder); }