private Lazy <IConsumer, EventConsumerMetadata> CreateConsumerRegistration(IConsumer consumer, bool isActive = true) { var metadata = new EventConsumerMetadata { IsActive = isActive, ContainerType = consumer.GetType() }; return(new Lazy <IConsumer, EventConsumerMetadata>(() => consumer, metadata)); }
private IEnumerable <MethodInfo> FindMethods(EventConsumerMetadata metadata) { var methods = metadata.ContainerType.GetMethods(BindingFlags.Public | BindingFlags.Instance); var validNames = new HashSet <string>(new[] { "Handle", "HandleEvent", "Consume", "HandleAsync", "HandleEventAsync", "ConsumeAsync" }); foreach (var method in methods) { if (validNames.Contains(method.Name)) { yield return(method); } } }