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

            var observer = new ScopedPublishPipeSpecificationObserver(filterType, lifetimeScopeProvider);

            configurator.ConfigurePublish(cfg => cfg.ConnectPublishPipeSpecificationObserver(observer));
        }
        /// <summary>
        /// Use scoped filter for <see cref="PublishContext{T}" />
        /// </summary>
        /// <param name="configurator"></param>
        /// <param name="filterType">Filter type</param>
        /// <param name="registration">Registration Context</param>
        public static void UsePublishFilter(this IPublishPipelineConfigurator 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 ScopedPublishPipeSpecificationObserver(filterType, provider);

            configurator.ConfigurePublish(cfg => cfg.ConnectPublishPipeSpecificationObserver(observer));
        }