소스 검색

add get all topics

undefined
Savorboard 6 년 전
부모
커밋
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;
}
}
}

불러오는 중...
취소
저장