Commit 2eaca664 authored by Savorboard's avatar Savorboard

supports one method subscribing multiple messages.

parent a1bec855
...@@ -58,13 +58,7 @@ namespace DotNetCore.CAP.Internal ...@@ -58,13 +58,7 @@ namespace DotNetCore.CAP.Internal
continue; continue;
} }
foreach (var method in typeInfo.DeclaredMethods) executorDescriptorList.AddRange(GetTopicAttributesDescription(typeInfo));
{
var topicAttr = method.GetCustomAttribute<TopicAttribute>(true);
if (topicAttr == null) continue;
executorDescriptorList.Add(InitDescriptor(topicAttr, method, typeInfo));
}
} }
return executorDescriptorList; return executorDescriptorList;
} }
...@@ -82,16 +76,25 @@ namespace DotNetCore.CAP.Internal ...@@ -82,16 +76,25 @@ namespace DotNetCore.CAP.Internal
//double check //double check
if (!Helper.IsController(typeInfo)) continue; if (!Helper.IsController(typeInfo)) continue;
executorDescriptorList.AddRange(GetTopicAttributesDescription(typeInfo));
}
return executorDescriptorList;
}
private static IEnumerable<ConsumerExecutorDescriptor> GetTopicAttributesDescription(TypeInfo typeInfo)
{
foreach (var method in typeInfo.DeclaredMethods) foreach (var method in typeInfo.DeclaredMethods)
{ {
var topicAttr = method.GetCustomAttribute<TopicAttribute>(true); var topicAttrs = method.GetCustomAttributes<TopicAttribute>(true);
if (topicAttr == null) continue;
if (topicAttrs.Count() == 0) continue;
executorDescriptorList.Add(InitDescriptor(topicAttr, method, typeInfo)); foreach (var attr in topicAttrs)
{
yield return InitDescriptor(attr, method, typeInfo);
} }
} }
return executorDescriptorList;
} }
private static ConsumerExecutorDescriptor InitDescriptor( private static ConsumerExecutorDescriptor InitDescriptor(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment