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,18 +76,27 @@ namespace DotNetCore.CAP.Internal ...@@ -82,18 +76,27 @@ namespace DotNetCore.CAP.Internal
//double check //double check
if (!Helper.IsController(typeInfo)) continue; if (!Helper.IsController(typeInfo)) 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;
} }
private static IEnumerable<ConsumerExecutorDescriptor> GetTopicAttributesDescription(TypeInfo typeInfo)
{
foreach (var method in typeInfo.DeclaredMethods)
{
var topicAttrs = method.GetCustomAttributes<TopicAttribute>(true);
if (topicAttrs.Count() == 0) continue;
foreach (var attr in topicAttrs)
{
yield return InitDescriptor(attr, method, typeInfo);
}
}
}
private static ConsumerExecutorDescriptor InitDescriptor( private static ConsumerExecutorDescriptor InitDescriptor(
TopicAttribute attr, TopicAttribute attr,
MethodInfo methodInfo, MethodInfo methodInfo,
......
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