From 58eaa7a21118ac4d5427f7179764c0f7d13ad416 Mon Sep 17 00:00:00 2001 From: ElderJames Date: Thu, 18 Jan 2018 18:34:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(client):=20=E5=85=81=E8=AE=B8=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=89=93=E4=BB=BB=E4=BD=95=E7=89=B9=E6=80=A7=E7=9A=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=A2=AB=E8=AE=BE=E7=BD=AE=E6=88=90=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E5=92=8C=E5=AE=A2=E6=88=B7=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ITcpTestService.cs => ISimpleInterface.cs} | 2 +- samples/Shriek.Samples.WebApiProxy/Program.cs | 11 +++++------ .../{TcpTestService.cs => ISimpleInterface.cs} | 2 +- src/Shriek.ServiceProxy.Http/WebApiProxyExtensions.cs | 3 +-- 4 files changed, 8 insertions(+), 10 deletions(-) rename samples/Shriek.Samples.WebApiProxy/Contracts/{ITcpTestService.cs => ISimpleInterface.cs} (78%) rename samples/Shriek.Samples.WebApiProxy/Services/{TcpTestService.cs => ISimpleInterface.cs} (84%) diff --git a/samples/Shriek.Samples.WebApiProxy/Contracts/ITcpTestService.cs b/samples/Shriek.Samples.WebApiProxy/Contracts/ISimpleInterface.cs similarity index 78% rename from samples/Shriek.Samples.WebApiProxy/Contracts/ITcpTestService.cs rename to samples/Shriek.Samples.WebApiProxy/Contracts/ISimpleInterface.cs index 417670b..7c43f66 100644 --- a/samples/Shriek.Samples.WebApiProxy/Contracts/ITcpTestService.cs +++ b/samples/Shriek.Samples.WebApiProxy/Contracts/ISimpleInterface.cs @@ -2,7 +2,7 @@ namespace Shriek.Samples.WebApiProxy.Contracts { - public interface ITcpTestService + public interface ISimpleInterface { Task Test(string sth); } diff --git a/samples/Shriek.Samples.WebApiProxy/Program.cs b/samples/Shriek.Samples.WebApiProxy/Program.cs index 988f959..4242022 100644 --- a/samples/Shriek.Samples.WebApiProxy/Program.cs +++ b/samples/Shriek.Samples.WebApiProxy/Program.cs @@ -25,6 +25,7 @@ public static void Main(string[] args) { opt.AddWebApiProxy(); opt.AddWebApiProxy(); + opt.AddService(); }); //服务里注册代理客户端 @@ -42,13 +43,14 @@ public static void Main(string[] args) { opt.AddWebApiProxy("http://localhost:8081"); opt.AddWebApiProxy("http://localhost:8080"); + opt.AddService("http://localhost:8080"); }) .BuildServiceProvider(); var todoService = provider.GetService(); var testService = provider.GetService(); var sampleTestService = provider.GetService(); - var tcpService = provider.GetService(); + var tcpService = provider.GetService(); Console.ReadKey(); @@ -71,11 +73,8 @@ public static void Main(string[] args) var result3 = sampleTestService.Test("elderjames").Result; Console.WriteLine(JsonConvert.SerializeObject(result3)); - Console.WriteLine("press any key to tcp testing..."); - Console.ReadKey(); - - //var result4 = tcpService.Test("hahaha").Result; - //Console.WriteLine(JsonConvert.SerializeObject(result4)); + var result4 = tcpService.Test("hahaha").Result; + Console.WriteLine(JsonConvert.SerializeObject(result4)); Console.ReadKey(); } diff --git a/samples/Shriek.Samples.WebApiProxy/Services/TcpTestService.cs b/samples/Shriek.Samples.WebApiProxy/Services/ISimpleInterface.cs similarity index 84% rename from samples/Shriek.Samples.WebApiProxy/Services/TcpTestService.cs rename to samples/Shriek.Samples.WebApiProxy/Services/ISimpleInterface.cs index f0413e3..b2a3008 100644 --- a/samples/Shriek.Samples.WebApiProxy/Services/TcpTestService.cs +++ b/samples/Shriek.Samples.WebApiProxy/Services/ISimpleInterface.cs @@ -3,7 +3,7 @@ namespace Shriek.Samples.WebApiProxy.Services { - public class TcpTestService : ITcpTestService + public class SimpleInterface : ISimpleInterface { public async Task Test(string sth) { diff --git a/src/Shriek.ServiceProxy.Http/WebApiProxyExtensions.cs b/src/Shriek.ServiceProxy.Http/WebApiProxyExtensions.cs index c49918a..69fd95a 100644 --- a/src/Shriek.ServiceProxy.Http/WebApiProxyExtensions.cs +++ b/src/Shriek.ServiceProxy.Http/WebApiProxyExtensions.cs @@ -45,8 +45,7 @@ public static IServiceCollection AddWebApiProxy(this IServiceCollection service, foreach (var type in option.RegisteredServices) { - if (type.Value.IsInterface && type.Value.GetMethods() - .SelectMany(m => m.GetCustomAttributes(typeof(ApiActionAttribute), true)).Any()) + if (type.Value.IsInterface/* && type.Value.GetMethods().SelectMany(m => m.GetCustomAttributes(typeof(ApiActionAttribute), true)).Any()*/) { var proxy = ProxyGenerator.CreateInterfaceProxyWithoutTarget(type.Value, new HttpApiClient(type.Key ?? option.ProxyHost)); service.AddSingleton(type.Value, x => proxy);