Преглед на файлове

add get all topics

undefined
Savorboard преди 7 години
родител
ревизия
8bfd066fce
променени са 1 файла, в които са добавени 23 реда и са изтрити 1 реда
  1. +23
    -1
      src/DotNetCore.CAP/Internal/MethodMatcherCache.cs

+ 23
- 1
src/DotNetCore.CAP/Internal/MethodMatcherCache.cs Целия файл

@@ -2,13 +2,13 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using DotNetCore.CAP.Abstractions;

namespace DotNetCore.CAP.Internal
{
internal class MethodMatcherCache
{
private readonly IConsumerServiceSelector _selector;
private List<string> _allTopics;

public MethodMatcherCache(IConsumerServiceSelector selector)
{
@@ -54,5 +54,27 @@ namespace DotNetCore.CAP.Internal
}
return dic;
}

/// <summary>
/// Get all subscribe topics name.
/// </summary>
public IEnumerable<string> GetSubscribeTopics()
{
if (_allTopics != null)
{
return _allTopics;
}

if (Entries == null)
throw new ArgumentNullException(nameof(Entries));

_allTopics = new List<string>();

foreach (var descriptors in Entries.Values)
{
_allTopics.AddRange(descriptors.Select(x => x.Attribute.Name));
}
return _allTopics;
}
}
}

Зареждане…
Отказ
Запис