Exemple #1
0
        /// <summary>
        /// Use scoped filter for <see cref="ConsumeContext{T}" />
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="filterType">Filter type</param>
        /// <param name="provider">Configuration service provider</param>
        public static void UseConsumeFilter(this IConsumePipeConfigurator configurator, Type filterType, IConfigurationServiceProvider provider)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            var lifetimeScope = provider.GetRequiredService <ILifetimeScope>();
            ILifetimeScopeProvider lifetimeScopeProvider = new SingleLifetimeScopeProvider(lifetimeScope);

            configurator.UseConsumeFilter(filterType, lifetimeScopeProvider);
        }