/// <summary> /// Adds an <see cref="IReceiver"/> to the service collection. /// </summary> /// <param name="services">The <see cref="IServiceCollection"/>.</param> /// <param name="registration"> /// The registration delegate that is responsible for creating the <see cref="IReceiver"/>. /// </param> /// <param name="lifetime">The <see cref="ServiceLifetime"/> of the receiver.</param> /// <returns>A new <see cref="IReceiverBuilder"/> for decorating the <see cref="IReceiver"/>.</returns> public static IReceiverBuilder AddReceiver(this IServiceCollection services, ReceiverRegistration registration, ServiceLifetime lifetime = _defaultLifetime) { if (services is null) { throw new ArgumentNullException(nameof(services)); } if (registration is null) { throw new ArgumentNullException(nameof(registration)); } var builder = new ReceiverBuilder(registration); services.Add(new ServiceDescriptor(typeof(IReceiver), builder.Build, lifetime)); services.SetReceiverLookupDescriptor(); return(builder); }
/// <summary> /// Initializes a new instance of the <see cref="ReceiverBuilder"/> class. /// </summary> /// <param name="registration"> /// The registration delegate that is responsible for creating the <see cref="IReceiver"/>. /// </param> public ReceiverBuilder(ReceiverRegistration registration) =>