/// <summary>
        /// 异步执行<see cref="ServiceLifetime.Scoped"/>生命周期的业务逻辑
        /// 1.当前处理<see cref="ServiceLifetime.Scoped"/>生命周期外,使用CreateScope创建<see cref="ServiceLifetime.Scoped"/>
        /// 生命周期的ServiceProvider来执行,并释放资源
        /// 2.当前处于<see cref="ServiceLifetime.Scoped"/>生命周期内,直接使用<see cref="ServiceLifetime.Scoped"/>的ServiceProvider来执行
        /// </summary>
        public static async Task ExecuteScopedWorkAsync(this IServiceProvider provider, Func <IServiceProvider, Task> action)
        {
            IHybridServiceScopeFactory factory = provider.GetService <IHybridServiceScopeFactory>();

            using (IServiceScope scope = factory.CreateScope())
            {
                await action(scope.ServiceProvider);
            }
        }
Ejemplo n.º 2
0
 public TemplateContentProvider(
     ITemplateDefinitionManager templateDefinitionManager,
     IHybridServiceScopeFactory serviceScopeFactory,
     IOptions <PlusTextTemplatingOptions> options)
 {
     ServiceScopeFactory        = serviceScopeFactory;
     Options                    = options.Value;
     _templateDefinitionManager = templateDefinitionManager;
 }
        /// <summary>
        /// 执行<see cref="ServiceLifetime.Scoped"/>生命周期的业务逻辑,并获取返回值
        /// 1.当前处理<see cref="ServiceLifetime.Scoped"/>生命周期外,使用CreateScope创建<see cref="ServiceLifetime.Scoped"/>
        /// 生命周期的ServiceProvider来执行,并释放资源
        /// 2.当前处于<see cref="ServiceLifetime.Scoped"/>生命周期内,直接使用<see cref="ServiceLifetime.Scoped"/>的ServiceProvider来执行
        /// </summary>
        public static async Task <TResult> ExecuteScopedWorkAsync <TResult>(this IServiceProvider provider, Func <IServiceProvider, Task <TResult> > func)
        {
            IHybridServiceScopeFactory factory = provider.GetService <IHybridServiceScopeFactory>();

            using (IServiceScope scope = factory.CreateScope())
            {
                return(await func(scope.ServiceProvider));
            }
        }
Ejemplo n.º 4
0
 public ReNameCommand(IOptions <AbpCliOptions> cliOptions,
                      IHybridServiceScopeFactory serviceScopeFactory,
                      ITemplateInfoProvider templateInfoProvider)
 {
     ServiceScopeFactory = serviceScopeFactory;
     Logger               = NullLogger <ReNameCommand> .Instance;
     AbpCliOptions        = cliOptions.Value;
     TemplateInfoProvider = templateInfoProvider;
 }
Ejemplo n.º 5
0
 public MenuManager(
     IOptions <AbpNavigationOptions> options,
     IHybridServiceScopeFactory serviceScopeFactory,
     ISimpleStateCheckerManager <ApplicationMenuItem> simpleStateCheckerManager)
 {
     Options                   = options.Value;
     ServiceScopeFactory       = serviceScopeFactory;
     SimpleStateCheckerManager = simpleStateCheckerManager;
 }
        /// <summary>
        /// 执行<see cref="ServiceLifetime.Scoped"/>生命周期的业务逻辑
        /// 1.当前处理<see cref="ServiceLifetime.Scoped"/>生命周期外,使用CreateScope创建<see cref="ServiceLifetime.Scoped"/>
        /// 生命周期的ServiceProvider来执行,并释放资源
        /// 2.当前处于<see cref="ServiceLifetime.Scoped"/>生命周期内,直接使用<see cref="ServiceLifetime.Scoped"/>的ServiceProvider来执行
        /// </summary>
        public static void ExecuteScopedWork(this IServiceProvider provider, Action <IServiceProvider> action)
        {
            IHybridServiceScopeFactory factory = provider.GetService <IHybridServiceScopeFactory>();

            using (IServiceScope scope = factory.CreateScope())
            {
                action(scope.ServiceProvider);
            }
        }
Ejemplo n.º 7
0
 public LocalDistributedEventBus(
     ILocalEventBus localEventBus,
     IHybridServiceScopeFactory serviceScopeFactory,
     IOptions <DistributedEventBusOptions> distributedEventBusOptions)
 {
     _localEventBus             = localEventBus;
     ServiceScopeFactory        = serviceScopeFactory;
     DistributedEventBusOptions = distributedEventBusOptions.Value;
     Subscribe(distributedEventBusOptions.Value.Handlers);
 }
Ejemplo n.º 8
0
 public AbpCorsPolicyService(
     IDistributedCache <AllowedCorsOriginsCacheItem> cache,
     IHybridServiceScopeFactory hybridServiceScopeFactory,
     IOptions <IdentityServerOptions> options)
 {
     Cache = cache;
     HybridServiceScopeFactory = hybridServiceScopeFactory;
     Options = options.Value;
     Logger  = NullLogger <AbpCorsPolicyService> .Instance;
 }
Ejemplo n.º 9
0
        public LocalEventBus(
            IOptions <LocalEventBusOptions> options,
            IHybridServiceScopeFactory serviceScopeFactory)
            : base(serviceScopeFactory)
        {
            Options = options.Value;
            Logger  = NullLogger <LocalEventBus> .Instance;

            HandlerFactories = new ConcurrentDictionary <Type, List <IEventHandlerFactory> >();
            SubscribeHandlers(Options.Handlers);
        }
Ejemplo n.º 10
0
        public CliService(
            ICommandLineArgumentParser commandLineArgumentParser,
            ICommandSelector commandSelector,
            IHybridServiceScopeFactory serviceScopeFactory)
        {
            CommandLineArgumentParser = commandLineArgumentParser;
            CommandSelector           = commandSelector;
            ServiceScopeFactory       = serviceScopeFactory;

            Logger = NullLogger <CliService> .Instance;
        }
Ejemplo n.º 11
0
 public DistributedCache(
     IOptions <AbpDistributedCacheOptions> distributedCacheOption,
     IDistributedCache cache,
     ICancellationTokenProvider cancellationTokenProvider,
     IDistributedCacheSerializer serializer,
     IDistributedCacheKeyNormalizer keyNormalizer,
     IHybridServiceScopeFactory serviceScopeFactory) : base(
         distributedCacheOption: distributedCacheOption,
         cache: cache,
         cancellationTokenProvider: cancellationTokenProvider,
         serializer: serializer,
         keyNormalizer: keyNormalizer,
         serviceScopeFactory: serviceScopeFactory)
 {
 }
        public CaptainHookPublisherManager(
            IHybridServiceScopeFactory serviceScopeFactory,
            IDistributedEventBus eventBus,
            IOptions <CaptainHookPublisherOptions> options,
            IOptions <CaptainHookPublisherRegistryOptions> registry)
        {
            ServiceScopeFactory = serviceScopeFactory;
            EventBus            = eventBus;
            Options             = options.Value;
            Registry            = registry.Value;

            EventTypes = new ConcurrentDictionary <string, Type>();

            Logger = NullLogger <CaptainHookPublisherManager> .Instance;
        }
Ejemplo n.º 13
0
 public TwoFactorAbpResourceOwnerPasswordValidator(
     UserManager <Volo.Abp.Identity.IdentityUser> userManager,
     SignInManager <Volo.Abp.Identity.IdentityUser> signInManager,
     IdentitySecurityLogManager identitySecurityLogManager,
     ILogger <ResourceOwnerPasswordValidator <Volo.Abp.Identity.IdentityUser> > logger,
     IStringLocalizer <AbpIdentityServerResource> localizer,
     IOptions <AbpIdentityOptions> abpIdentityOptions,
     IHybridServiceScopeFactory serviceScopeFactory,
     ISettingProvider settingProvider,
     IServiceProvider serviceProvider,
     IOptions <IdentityOptions> identityOptions) :
     base(userManager, signInManager, identitySecurityLogManager, logger, localizer, abpIdentityOptions, serviceScopeFactory, identityOptions)
 {
     this.settingProvider = settingProvider;
     ServiceProvider      = serviceProvider;
 }
Ejemplo n.º 14
0
        private IEventHandlerFactory CreateFactory(IHybridServiceScopeFactory serviceProvider)
        {
            switch (ActivationType)
            {
            case EventHandlerActivationType.ByServiceProvider:
                return(new IocEventHandlerFactory(serviceProvider, HandlerType));

            case EventHandlerActivationType.Singleton:
                return(new SingleInstanceHandlerFactory(Activator.CreateInstance(HandlerType) as IEventHandler));

            case EventHandlerActivationType.Transient:
                return(new TransientEventHandlerFactory(HandlerType));

            default:
                return(null);
            }
        }
Ejemplo n.º 15
0
 public AbpResourceOwnerPasswordValidator(
     UserManager <IdentityUser> userManager,
     SignInManager <IdentityUser> signInManager,
     IdentitySecurityLogManager identitySecurityLogManager,
     ILogger <ResourceOwnerPasswordValidator <IdentityUser> > logger,
     IStringLocalizer <AbpIdentityServerResource> localizer,
     IOptions <AbpIdentityOptions> abpIdentityOptions,
     IHybridServiceScopeFactory serviceScopeFactory)
 {
     UserManager   = userManager;
     SignInManager = signInManager;
     IdentitySecurityLogManager = identitySecurityLogManager;
     Logger              = logger;
     Localizer           = localizer;
     ServiceScopeFactory = serviceScopeFactory;
     AbpIdentityOptions  = abpIdentityOptions.Value;
 }
Ejemplo n.º 16
0
        public RabbitMqDistributedEventBus(
            IOptions <RabbitMqEventBusOptions> options,
            IConnectionPool connectionPool,
            IRabbitMqSerializer serializer,
            IHybridServiceScopeFactory serviceScopeFactory,
            IOptions <DistributedEventBusOptions> distributedEventBusOptions,
            IRabbitMqMessageConsumerFactory messageConsumerFactory)
            : base(serviceScopeFactory)
        {
            ConnectionPool             = connectionPool;
            Serializer                 = serializer;
            MessageConsumerFactory     = messageConsumerFactory;
            DistributedEventBusOptions = distributedEventBusOptions.Value;
            RabbitMqEventBusOptions    = options.Value;

            HandlerFactories = new ConcurrentDictionary <Type, List <IEventHandlerFactory> >();
            EventTypes       = new ConcurrentDictionary <string, Type>();
        }
Ejemplo n.º 17
0
        public RabbitMqDistributedEventBus(
            IOptions <RabbitMqDistributedEventBusOptions> options,
            IConnectionPool connectionPool,
            IRabbitMqSerializer serializer,
            IHybridServiceScopeFactory serviceScopeFactory,
            IOptions <DistributedEventBusOptions> distributedEventBusOptions)
        {
            ConnectionPool                     = connectionPool;
            Serializer                         = serializer;
            ServiceScopeFactory                = serviceScopeFactory;
            DistributedEventBusOptions         = distributedEventBusOptions.Value;
            RabbitMqDistributedEventBusOptions = options.Value;

            HandlerFactories = new ConcurrentDictionary <Type, List <IEventHandlerFactory> >();
            EventTypes       = new ConcurrentDictionary <string, Type>();

            ConsumerChannel = CreateConsumerChannel();
            Subscribe(DistributedEventBusOptions.Handlers);
        }
Ejemplo n.º 18
0
        public RabbitMqDistributedEventBus(
            IOptions <RabbitMqEventBusOptions> options,
            IConnectionPool connectionPool,
            IRabbitMqSerializer serializer,
            IHybridServiceScopeFactory serviceScopeFactory,
            IOptions <DistributedEventBusOptions> distributedEventBusOptions,
            IRabbitMqMessageConsumerFactory messageConsumerFactory)
            : base(serviceScopeFactory)
        {
            ConnectionPool             = connectionPool;
            Serializer                 = serializer;
            MessageConsumerFactory     = messageConsumerFactory;
            DistributedEventBusOptions = distributedEventBusOptions.Value;
            RabbitMqEventBusOptions    = options.Value;

            HandlerFactories = new ConcurrentDictionary <Type, List <IEventHandlerFactory> >();
            EventTypes       = new ConcurrentDictionary <string, Type>();

            Consumer = MessageConsumerFactory.Create(
                new ExchangeDeclareConfiguration(
                    RabbitMqEventBusOptions.ExchangeName,
                    type: "direct",
                    durable: true
                    ),
                new QueueDeclareConfiguration(
                    RabbitMqEventBusOptions.ClientName,
                    durable: true,
                    exclusive: false,
                    autoDelete: false
                    ),
                RabbitMqEventBusOptions.ConnectionName
                );

            Consumer.OnMessageReceived(ProcessEventAsync);

            SubscribeHandlers(DistributedEventBusOptions.Handlers);
        }
Ejemplo n.º 19
0
 public ObjectValidator(IOptions <RocketValidationOptions> options, IHybridServiceScopeFactory serviceScopeFactory)
 {
     ServiceScopeFactory = serviceScopeFactory;
     Options             = options.Value;
 }
Ejemplo n.º 20
0
 public GenerateProxyCommand(
     IOptions <AbpCliServiceProxyOptions> serviceProxyOptions,
     IHybridServiceScopeFactory serviceScopeFactory)
     : base(serviceProxyOptions, serviceScopeFactory)
 {
 }
Ejemplo n.º 21
0
 public LocalEventBus(IOptions <EventBusOptions> options, IHybridServiceScopeFactory serviceScopeFactory) : base(options, serviceScopeFactory)
 {
     Logger = NullLogger <LocalEventBus> .Instance;
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExceptionNotifier"/> class.
 /// </summary>
 /// <param name="serviceScopeFactory">The service scope factory.</param>
 public ExceptionNotifier(IHybridServiceScopeFactory serviceScopeFactory)
 {
     ServiceScopeFactory = serviceScopeFactory;
     Logger = NullLogger <ExceptionNotifier> .Instance;
 }
Ejemplo n.º 23
0
 /// <summary>
 /// 初始化一个<see cref="PassThroughEventBus"/>类型的新实例
 /// </summary>
 public PassThroughEventBus(IHybridServiceScopeFactory serviceScopeFactory, IServiceProvider serviceProvider)
     : base(serviceScopeFactory, serviceProvider)
 {
 }
Ejemplo n.º 24
0
 protected EventBusBase(IHybridServiceScopeFactory serviceScopeFactory)
 {
     ServiceScopeFactory = serviceScopeFactory;
 }
 public IocEventHandlerFactory(IHybridServiceScopeFactory scopeFactory, Type handlerType)
 {
     HandlerType  = handlerType;
     ServiceScope = scopeFactory.CreateScope();
 }
Ejemplo n.º 26
0
 public LdapManager(IOptions <RocketLdapOptions> ldapSettingsOptions, IHybridServiceScopeFactory hybridServiceScopeFactory)
 {
     _hybridServiceScopeFactory = hybridServiceScopeFactory;
     _ldapOptions = ldapSettingsOptions.Value;
     _searchBase  = _ldapOptions.SearchBase;
 }
Ejemplo n.º 27
0
 public IocEventHandlerFactory(IHybridServiceScopeFactory scopeFactory, Type handlerType)
 {
     ScopeFactory = scopeFactory;
     HandlerType  = handlerType;
 }
Ejemplo n.º 28
0
 public TransientEventHandlerFactory(IHybridServiceScopeFactory serviceScopeFactory) : base(serviceScopeFactory, typeof(THandler))
 {
 }
Ejemplo n.º 29
0
 public PageToolbarManager(
     IHybridServiceScopeFactory serviceScopeFactory)
 {
     ServiceScopeFactory = serviceScopeFactory;
 }
Ejemplo n.º 30
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="serviceScopeFactory"></param>
 public ExceptionNotifier(IHybridServiceScopeFactory serviceScopeFactory)
 {
     ServiceScopeFactory = Check.NotNull(serviceScopeFactory, nameof(serviceScopeFactory));
     Logger = NullLogger <ExceptionNotifier> .Instance;
 }