예제 #1
0
        /// <summary>
        /// Use scoped filter for <see cref="SendContext{T}" />
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="filterType">Filter type</param>
        /// <param name="lifetimeScopeProvider">Lifetime Scope Provider</param>
        public static void UseSendFilter(this ISendPipelineConfigurator configurator, Type filterType, ILifetimeScopeProvider lifetimeScopeProvider)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }
            if (lifetimeScopeProvider == null)
            {
                throw new ArgumentNullException(nameof(lifetimeScopeProvider));
            }

            var observer = new ScopedSendPipeSpecificationObserver(filterType, lifetimeScopeProvider);

            configurator.ConfigureSend(cfg => cfg.ConnectSendPipeSpecificationObserver(observer));
        }
        /// <summary>
        /// Use scoped filter for <see cref="SendContext{T}" />
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="filterType">Filter type</param>
        /// <param name="registration">Registration Context</param>
        public static void UseSendFilter(this ISendPipelineConfigurator configurator, Type filterType, IRegistration registration)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }
            if (registration == null)
            {
                throw new ArgumentNullException(nameof(registration));
            }

            var provider = registration.GetRequiredService <IServiceProvider>();
            var observer = new ScopedSendPipeSpecificationObserver(filterType, provider);

            configurator.ConfigureSend(cfg => cfg.ConnectSendPipeSpecificationObserver(observer));
        }