Skip to content

Commit

Permalink
Merge pull request #298 from robpalm/robpalm/issue294
Browse files Browse the repository at this point in the history
Added Optional Setting to name the IServiceCollection Extension Method by @robpalm
  • Loading branch information
christianhelle authored Jan 18, 2024
2 parents e13e305 + 3c72051 commit 2e6a261
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Refitter.Core/DependencyInjectionGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public static string Generate(
var code = new StringBuilder();

var methodDeclaration = string.IsNullOrEmpty(iocSettings.BaseUrl)
? "public static IServiceCollection ConfigureRefitClients(this IServiceCollection services, Uri baseUrl, Action<IHttpClientBuilder>? builder = default)"
: "public static IServiceCollection ConfigureRefitClients(this IServiceCollection services, Action<IHttpClientBuilder>? builder = default)";
? $"public static IServiceCollection {iocSettings.ExtensionMethodName}(this IServiceCollection services, Uri baseUrl, Action<IHttpClientBuilder>? builder = default)"
: $"public static IServiceCollection {iocSettings.ExtensionMethodName}(this IServiceCollection services, Action<IHttpClientBuilder>? builder = default)";

var configureRefitClient = string.IsNullOrEmpty(iocSettings.BaseUrl)
? ".ConfigureHttpClient(c => c.BaseAddress = baseUrl)"
Expand Down
5 changes: 5 additions & 0 deletions src/Refitter.Core/Settings/DependencyInjectionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ public class DependencyInjectionSettings
/// The median delay to target before the first retry in seconds. Default is 1 second
/// </summary>
public double FirstBackoffRetryInSeconds { get; set; } = 1.0;

/// <summary>
/// Name of IServiceCollection Extension Method. Default is ConfigureRefitClients
/// </summary>
public string ExtensionMethodName { get; set; } = "ConfigureRefitClients";
}

0 comments on commit 2e6a261

Please sign in to comment.