Browse Source

add get all topics

undefined
Savorboard 6 years ago
parent
commit
8bfd066fce
1 changed files with 23 additions and 1 deletions
  1. +23
    -1
      src/DotNetCore.CAP/Internal/MethodMatcherCache.cs

+ 23
- 1
src/DotNetCore.CAP/Internal/MethodMatcherCache.cs View File

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


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


public MethodMatcherCache(IConsumerServiceSelector selector) public MethodMatcherCache(IConsumerServiceSelector selector)
{ {
@@ -54,5 +54,27 @@ namespace DotNetCore.CAP.Internal
} }
return dic; 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;
}
} }
} }

Loading…
Cancel
Save