Quellcode durchsuchen

Change ISubscribeInvoker interface access modifier. #537

master
Savorboard vor 4 Jahren
Ursprung
Commit
879d147175
3 geänderte Dateien mit 23 neuen und 17 gelöschten Zeilen
  1. +1
    -1
      src/DotNetCore.CAP/Internal/ConsumerExecutedResult.cs
  2. +21
    -15
      src/DotNetCore.CAP/Internal/ISubscribeInvoker.Default.cs
  3. +1
    -1
      src/DotNetCore.CAP/Internal/ISubscribeInvoker.cs

+ 1
- 1
src/DotNetCore.CAP/Internal/ConsumerExecutedResult.cs Datei anzeigen

@@ -3,7 +3,7 @@

namespace DotNetCore.CAP.Internal
{
internal class ConsumerExecutedResult
public class ConsumerExecutedResult
{
public ConsumerExecutedResult(object result, string msgId, string callbackName)
{


+ 21
- 15
src/DotNetCore.CAP/Internal/ISubscribeInvoker.Default.cs Datei anzeigen

@@ -3,7 +3,6 @@

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -15,7 +14,7 @@ using Newtonsoft.Json.Linq;

namespace DotNetCore.CAP.Internal
{
internal class SubscribeInvoker : ISubscribeInvoker
public class SubscribeInvoker : ISubscribeInvoker
{
private readonly ILogger _logger;
private readonly IServiceProvider _serviceProvider;
@@ -41,20 +40,8 @@ namespace DotNetCore.CAP.Internal
using (var scope = _serviceProvider.CreateScope())
{
var provider = scope.ServiceProvider;
var srvType = context.ConsumerDescriptor.ServiceTypeInfo?.AsType();
var implType = context.ConsumerDescriptor.ImplTypeInfo.AsType();

object obj = null;

if (srvType != null)
{
obj = provider.GetServices(srvType).FirstOrDefault(o => o.GetType() == implType);
}

if (obj == null)
{
obj = ActivatorUtilities.GetServiceOrCreateInstance(provider, implType);
}
var obj = GetInstance(provider, context);

var message = context.DeliverMessage;
var parameterDescriptors = context.ConsumerDescriptor.Parameters;
@@ -83,6 +70,25 @@ namespace DotNetCore.CAP.Internal
}
}

protected virtual object GetInstance(IServiceProvider provider, ConsumerContext context)
{
var srvType = context.ConsumerDescriptor.ServiceTypeInfo?.AsType();
var implType = context.ConsumerDescriptor.ImplTypeInfo.AsType();

object obj = null;
if (srvType != null)
{
obj = provider.GetServices(srvType).FirstOrDefault(o => o.GetType() == implType);
}

if (obj == null)
{
obj = ActivatorUtilities.GetServiceOrCreateInstance(provider, implType);
}

return obj;
}

private async Task<object> ExecuteWithParameterAsync(ObjectMethodExecutor executor, object @class, object[] parameter)
{
if (executor.IsMethodAsync)


+ 1
- 1
src/DotNetCore.CAP/Internal/ISubscribeInvoker.cs Datei anzeigen

@@ -9,7 +9,7 @@ namespace DotNetCore.CAP.Internal
/// <summary>
/// Perform user definition method of consumers.
/// </summary>
internal interface ISubscribeInvoker
public interface ISubscribeInvoker
{
/// <summary>
/// Invoke subscribe method with the consumer context.


Laden…
Abbrechen
Speichern