forked from dotnetcore/WebApiClient
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
170 additions
and
283 deletions.
There are no files selected for viewing
64 changes: 0 additions & 64 deletions
64
WebApiClientCore.Test/DependencyInjectionExtensionsTest.cs
This file was deleted.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
WebApiClientCore/Microsoft.Extensions/DependencyInjection/HttpApiConfigureExtensions.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using System; | ||
using WebApiClientCore; | ||
|
||
namespace Microsoft.Extensions.DependencyInjection | ||
{ | ||
/// <summary> | ||
/// HttpApi配置控制 | ||
/// </summary> | ||
public static class HttpApiConfigureExtensions | ||
{ | ||
/// <summary> | ||
/// 配置HttpApi | ||
/// </summary> | ||
/// <typeparam name="THttpApi"></typeparam> | ||
/// <param name="services"></param> | ||
/// <param name="configureOptions">配置选项</param> | ||
/// <returns></returns> | ||
public static IServiceCollection ConfigureHttpApi<THttpApi>(this IServiceCollection services, Action<HttpApiOptions> configureOptions) | ||
{ | ||
return services.ConfigureHttpApi(typeof(THttpApi), configureOptions); | ||
} | ||
|
||
/// <summary> | ||
/// 配置HttpApi | ||
/// </summary> | ||
/// <param name="services"></param> | ||
/// <param name="httpApiType">接口类型</param> | ||
/// <param name="configureOptions">配置选项</param> | ||
/// <returns></returns> | ||
public static IServiceCollection ConfigureHttpApi(this IServiceCollection services, Type httpApiType, Action<HttpApiOptions> configureOptions) | ||
{ | ||
return services.Configure(httpApiType.FullName, configureOptions); | ||
} | ||
|
||
/// <summary> | ||
/// 配置HttpApi | ||
/// </summary> | ||
/// <typeparam name="THttpApi"></typeparam> | ||
/// <param name="services"></param> | ||
/// <param name="configureOptions">配置选项</param> | ||
/// <returns></returns> | ||
public static IServiceCollection ConfigureHttpApi<THttpApi>(this IServiceCollection services, IConfiguration configureOptions) | ||
{ | ||
return services.ConfigureHttpApi(typeof(THttpApi), configureOptions); | ||
} | ||
|
||
/// <summary> | ||
/// 配置HttpApi | ||
/// </summary> | ||
/// <param name="services"></param> | ||
/// <param name="httpApiType">接口类型</param> | ||
/// <param name="configureOptions">配置选项</param> | ||
/// <returns></returns> | ||
public static IServiceCollection ConfigureHttpApi(this IServiceCollection services, Type httpApiType, IConfiguration configureOptions) | ||
{ | ||
return services.Configure<HttpApiOptions>(httpApiType.FullName, configureOptions); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.