private IEnumerable <ConsumerExecutorDescriptor> GetSubscribeAttributesDescription(TypeInfo typeInfo, TypeInfo serviceTypeInfo = null) { SubscribeAttribute topicClassAttribute = typeInfo.GetCustomAttribute <SubscribeAttribute>(inherit: true); foreach (MethodInfo method in typeInfo.GetRuntimeMethods()) { IEnumerable <SubscribeAttribute> topicMethodAttributes = method.GetCustomAttributes <SubscribeAttribute>(inherit: true); if (topicClassAttribute == null) { topicMethodAttributes = topicMethodAttributes.Where((SubscribeAttribute x) => !x.IsPartial); } if (!topicMethodAttributes.Any()) { continue; } foreach (SubscribeAttribute attr in topicMethodAttributes) { SetSubscribeAttribute(attr); List <ParameterDescriptor> parameters = (from parameter in method.GetParameters() select new ParameterDescriptor { Name = parameter.Name, ParameterType = parameter.ParameterType, IsFromCap = parameter.GetCustomAttributes(typeof(FromCapAttribute)).Any() }).ToList(); var subAttr = new CapSubscribeAttribute(attr.Name) { Group = attr.Group }; yield return(InitDescriptor(subAttr, method, typeInfo, serviceTypeInfo, parameters, subAttr)); } } }
/// <summary> /// 获取消费者标记 /// </summary> /// <param name="typeInfo"></param> /// <returns></returns> protected IEnumerable <ConsumerExecutorDescriptor> GetDescription(TypeInfo typeInfo) { foreach (var method in typeInfo.DeclaredMethods) { var parameters = method.GetParameters(); var parameterList = method.GetParameters() .Select(parameter => new ParameterDescriptor { Name = parameter.Name, ParameterType = parameter.ParameterType, IsFromCap = parameter.GetCustomAttributes(typeof(FromCapAttribute)).Any() }).ToList(); foreach (var parameter in parameters) { var type = parameter.ParameterType; var attr = new CapSubscribeAttribute(_options.TopicName); attr.Group = GetQueueName(); yield return(InitDescriptor(attr, method, typeInfo, parameterList)); } } }