Ejemplo n.º 1
0
        /// <summary>
        /// Adds an <see cref="ITransactionalSender"/> 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="ITransactionalSender"/>.
        /// </param>
        /// <param name="lifetime">The <see cref="ServiceLifetime"/> of the transactional sender.</param>
        /// <returns>A new <see cref="ITransactionalSenderBuilder"/> for decorating the <see cref="ITransactionalSender"/>.</returns>
        public static ITransactionalSenderBuilder AddTransactionalSender(this IServiceCollection services,
                                                                         TransactionalSenderRegistration 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 TransactionalSenderBuilder(registration);

            services.Add(new ServiceDescriptor(typeof(ITransactionalSender), builder.Build, lifetime));
            services.SetTransactionalSenderLookupDescriptor();
            services.SetSenderLookupDescriptor();

            return(builder);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TransactionalSenderBuilder"/> class.
 /// </summary>
 /// <param name="registration">
 /// The registration delegate that is responsible for creating the <see cref="ITransactionalSender"/>.
 /// </param>
 public TransactionalSenderBuilder(TransactionalSenderRegistration registration) =>