/// <summary> /// Adds registrations to the <paramref name="services"/> collection using /// conventions specified using the <paramref name="action"/>. /// </summary> /// <param name="services">The services to add to.</param> /// <param name="action">The configuration action.</param> /// <exception cref="ArgumentNullException">If either the <paramref name="services"/> /// or <paramref name="action"/> arguments are <c>null</c>.</exception> public static IServiceCollection Scan([NotNull] this IServiceCollection services, [NotNull] Action <ITypeSourceSelector> action) { // 选择器 var selector = new TypeSourceSelector(); action(selector); // 注册 return(services.Populate(selector, RegistrationStrategy.Append)); }
/// <summary> /// Adds the subscriber services to the messaging host. /// The subscriber services are background services (hosted services) that consume messages from the bus. /// </summary> /// <param name="builder">The builder is used to configure the message types or topics for which subscriber services are added.</param> /// <returns>The options builder</returns> public MessagingHostOptionsBuilder AddSubscriberServices(Action <ITypeSourceSelector> builder) { var subscriberServiceSelector = new TypeSourceSelector(ServiceCollection); builder?.Invoke(subscriberServiceSelector); var optionsBuilder = new MessagingHostOptionsBuilder(this, ServiceCollection, subscriberServiceSelector, subscriberServiceSelector); return(optionsBuilder); }
/// <summary> /// Adds registrations to the <paramref name="services"/> collection using /// conventions specified using the <paramref name="action"/>. /// </summary> /// <param name="services">The services to add to.</param> /// <param name="action">The configuration action.</param> /// <exception cref="ArgumentNullException">If either the <paramref name="services"/> /// or <paramref name="action"/> arguments are <c>null</c>.</exception> public static IServiceCollection Scan(this IServiceCollection services, Action <ITypeSourceSelector> action) { Preconditions.NotNull(services, nameof(services)); Preconditions.NotNull(action, nameof(action)); var selector = new TypeSourceSelector(); action(selector); return(services.Populate(selector, RegistrationStrategy.Append)); }
public static ActivityDefinitionList Discover( this ActivityDefinitionList list, Action <ITypeSourceSelector> selector) { var typeSourceSelector = new TypeSourceSelector(); selector(typeSourceSelector); var serviceCollection = new ServiceCollection(); typeSourceSelector.Populate(serviceCollection, RegistrationStrategy.Replace(ReplacementBehavior.All)); foreach (var service in serviceCollection) { list.Add(ActivityDescriber.Describe(service.ImplementationType)); } return(list); }