Przeglądaj źródła

Remove the subscriber factory and get it directly from DI

master
杨晓东 4 lat temu
rodzic
commit
21280211f6
4 zmienionych plików z 2 dodań i 39 usunięć
  1. +1
    -1
      src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs
  2. +0
    -27
      src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs
  3. +1
    -1
      src/DotNetCore.CAP/Internal/ISubscribeDispatcher.Default.cs
  4. +0
    -10
      src/DotNetCore.CAP/Internal/ISubscribeInvokerFactory.cs

+ 1
- 1
src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs Wyświetl plik

@@ -39,7 +39,7 @@ namespace Microsoft.Extensions.DependencyInjection
services.TryAddSingleton<ICapPublisher, CapPublisher>();

services.TryAddSingleton<IConsumerServiceSelector, ConsumerServiceSelector>();
services.TryAddSingleton<ISubscribeInvokerFactory, ConsumerInvokerFactory>();
services.TryAddSingleton<ISubscribeInvoker, SubscribeInvoker>();
services.TryAddSingleton<MethodMatcherCache>();

services.TryAddSingleton<IConsumerRegister, ConsumerRegister>();


+ 0
- 27
src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs Wyświetl plik

@@ -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);
}
}
}

+ 1
- 1
src/DotNetCore.CAP/Internal/ISubscribeDispatcher.Default.cs Wyświetl plik

@@ -38,7 +38,7 @@ namespace DotNetCore.CAP.Internal
_options = options.Value;

_dataStorage = _provider.GetService<IDataStorage>();
Invoker = _provider.GetService<ISubscribeInvokerFactory>().CreateInvoker();
Invoker = _provider.GetService<SubscribeInvoker>();
}

private ISubscribeInvoker Invoker { get; }


+ 0
- 10
src/DotNetCore.CAP/Internal/ISubscribeInvokerFactory.cs Wyświetl plik

@@ -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();
}
}

Ładowanie…
Anuluj
Zapisz