From 21280211f62d092ef4de1501887f8271a4a854ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=99=93=E4=B8=9C?= Date: Thu, 2 Apr 2020 18:06:08 +0800 Subject: [PATCH] Remove the subscriber factory and get it directly from DI --- .../CAP.ServiceCollectionExtensions.cs | 2 +- .../Internal/ConsumerInvokerFactory.cs | 27 ------------------- .../Internal/ISubscribeDispatcher.Default.cs | 2 +- .../Internal/ISubscribeInvokerFactory.cs | 10 ------- 4 files changed, 2 insertions(+), 39 deletions(-) delete mode 100644 src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs delete mode 100644 src/DotNetCore.CAP/Internal/ISubscribeInvokerFactory.cs diff --git a/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs b/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs index a12a6dc..55d5fbc 100644 --- a/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs +++ b/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs @@ -39,7 +39,7 @@ namespace Microsoft.Extensions.DependencyInjection services.TryAddSingleton(); services.TryAddSingleton(); - services.TryAddSingleton(); + services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(); diff --git a/src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs b/src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs deleted file mode 100644 index bfcb3d5..0000000 --- a/src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) .NET Core Community. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -using System; -using Microsoft.Extensions.Logging; - -namespace DotNetCore.CAP.Internal -{ - internal class ConsumerInvokerFactory : ISubscribeInvokerFactory - { - private readonly ILoggerFactory _loggerFactory; - private readonly IServiceProvider _serviceProvider; - - public ConsumerInvokerFactory( - ILoggerFactory loggerFactory, - IServiceProvider serviceProvider) - { - _loggerFactory = loggerFactory; - _serviceProvider = serviceProvider; - } - - public ISubscribeInvoker CreateInvoker() - { - return new SubscribeInvoker(_loggerFactory, _serviceProvider); - } - } -} \ No newline at end of file diff --git a/src/DotNetCore.CAP/Internal/ISubscribeDispatcher.Default.cs b/src/DotNetCore.CAP/Internal/ISubscribeDispatcher.Default.cs index a8a48c6..693557f 100644 --- a/src/DotNetCore.CAP/Internal/ISubscribeDispatcher.Default.cs +++ b/src/DotNetCore.CAP/Internal/ISubscribeDispatcher.Default.cs @@ -38,7 +38,7 @@ namespace DotNetCore.CAP.Internal _options = options.Value; _dataStorage = _provider.GetService(); - Invoker = _provider.GetService().CreateInvoker(); + Invoker = _provider.GetService(); } private ISubscribeInvoker Invoker { get; } diff --git a/src/DotNetCore.CAP/Internal/ISubscribeInvokerFactory.cs b/src/DotNetCore.CAP/Internal/ISubscribeInvokerFactory.cs deleted file mode 100644 index c8a582d..0000000 --- a/src/DotNetCore.CAP/Internal/ISubscribeInvokerFactory.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) .NET Core Community. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -namespace DotNetCore.CAP.Internal -{ - internal interface ISubscribeInvokerFactory - { - ISubscribeInvoker CreateInvoker(); - } -} \ No newline at end of file