Skip to content

Commit

Permalink
IHttpApiActivator实现类的重命名
Browse files Browse the repository at this point in the history
  • Loading branch information
xljiulang committed Jan 23, 2021
1 parent 54223bf commit b4b6187
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 22 deletions.
3 changes: 1 addition & 2 deletions App/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using WebApiClientCore;

namespace App
{
Expand Down Expand Up @@ -49,7 +48,7 @@ public void ConfigureServices(IServiceCollection services)
services
.AddWebApiClient()
.UseJsonFirstApiActionDescriptor()
.UseHttpApiSourceGeneratorActivator();
.UseSourceGeneratorHttpApiActivator();

// 注册userApi
services.AddHttpApi<IUserApi>(o =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public static class WebApiClientBuilderExtensions
/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
public static IWebApiClientBuilder UseHttpApiSourceGeneratorActivator(this IWebApiClientBuilder builder)
public static IWebApiClientBuilder UseSourceGeneratorHttpApiActivator(this IWebApiClientBuilder builder)
{
builder.Services.AddSingleton(typeof(IHttpApiActivator<>), typeof(HttpApiSourceGeneratorActivator<>));
builder.Services.AddSingleton(typeof(IHttpApiActivator<>), typeof(SourceGeneratorHttpApiActivator<>));
return builder;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace WebApiClientCore.Implementations
/// 通过查找类型代理类型创建实例
/// </summary>
/// <typeparam name="THttpApi"></typeparam>
public class HttpApiSourceGeneratorActivator<THttpApi> : HttpApiActivator<THttpApi>
public class SourceGeneratorHttpApiActivator<THttpApi> : HttpApiActivator<THttpApi>
{
/// <summary>
/// 通过查找类型代理类型创建实例
Expand All @@ -19,7 +19,7 @@ public class HttpApiSourceGeneratorActivator<THttpApi> : HttpApiActivator<THttpA
/// <param name="actionInvokerProvider"></param>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="NotSupportedException"></exception>
public HttpApiSourceGeneratorActivator(IApiActionDescriptorProvider apiActionDescriptorProvider, IApiActionInvokerProvider actionInvokerProvider)
public SourceGeneratorHttpApiActivator(IApiActionDescriptorProvider apiActionDescriptorProvider, IApiActionInvokerProvider actionInvokerProvider)
: base(apiActionDescriptorProvider, actionInvokerProvider)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,14 @@ public static IWebApiClientBuilder AddWebApiClient(this IServiceCollection servi
services.AddOptions();
services.AddMemoryCache();

services.TryAddSingleton(typeof(IHttpApiActivator<>), typeof(HttpApiEmitActivator<>));
services.TryAddSingleton(typeof(IHttpApiActivator<>), typeof(DefaultHttpApiActivator<>));
services.TryAddSingleton<IApiActionDescriptorProvider, DefaultApiActionDescriptorProvider>();
services.TryAddSingleton<IApiActionInvokerProvider, DefaultApiActionInvokerProvider>();
services.TryAddSingleton<IResponseCacheProvider, DefaultResponseCacheProvider>();

return new WebApiClientBuilder(services);
}

/// <summary>
/// 运行时使用Emit动态创建接口的代理类和代理类实例
/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
public static IWebApiClientBuilder UseHttpApiEmitActivator(this IWebApiClientBuilder builder)
{
builder.Services.AddSingleton(typeof(IHttpApiActivator<>), typeof(HttpApiEmitActivator<>));
return builder;
}

/// <summary>
/// 当非GET或HEAD请求的缺省参数特性声明时
/// 为复杂参数类型的参数应用JsonContentAttribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
namespace WebApiClientCore.Implementations
{
/// <summary>
/// 表示THttpApi的实例Emit创建器
/// 运行时使用Emit动态创建THttpApi的代理类和代理类实例
/// </summary>
/// <typeparam name="THttpApi"></typeparam>
public class HttpApiEmitActivator<THttpApi> : HttpApiActivator<THttpApi>
public class DefaultHttpApiActivator<THttpApi> : HttpApiActivator<THttpApi>
{
/// <summary>
/// IHttpApiInterceptor的Intercept方法
Expand All @@ -26,13 +26,13 @@ public class HttpApiEmitActivator<THttpApi> : HttpApiActivator<THttpApi>


/// <summary>
/// THttpApi的实例Emit创建器
/// 运行时使用Emit动态创建THttpApi的代理类和代理类实例
/// </summary>
/// <param name="apiActionDescriptorProvider"></param>
/// <param name="actionInvokerProvider"></param>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="NotSupportedException"></exception>
public HttpApiEmitActivator(IApiActionDescriptorProvider apiActionDescriptorProvider, IApiActionInvokerProvider actionInvokerProvider)
public DefaultHttpApiActivator(IApiActionDescriptorProvider apiActionDescriptorProvider, IApiActionInvokerProvider actionInvokerProvider)
: base(apiActionDescriptorProvider, actionInvokerProvider)
{
}
Expand Down

0 comments on commit b4b6187

Please sign in to comment.