public static IServiceCollection AddRabbitListeners <T>(this IServiceCollection services) where T : class { if (services == null) { throw new ArgumentNullException(nameof(services)); } var metadata = RabbitListenerMetadata.BuildMetadata(typeof(T)); if (metadata != null) { services.AddSingleton(metadata); services.AddSingleton <T>(); } return(services); }
public static IServiceCollection AddRabbitListeners(this IServiceCollection services, IConfiguration config, params Type[] listenerServices) { if (services == null) { throw new ArgumentNullException(nameof(services)); } foreach (var t in listenerServices) { var metadata = RabbitListenerMetadata.BuildMetadata(services, t); if (metadata != null) { services.AddSingleton(metadata); } RabbitListenerDeclareAtrributeProcessor.ProcessDeclareAttributes(services, config, t); } return(services); }