/// <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); } }
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)); } }
public ReNameCommand(IOptions <AbpCliOptions> cliOptions, IHybridServiceScopeFactory serviceScopeFactory, ITemplateInfoProvider templateInfoProvider) { ServiceScopeFactory = serviceScopeFactory; Logger = NullLogger <ReNameCommand> .Instance; AbpCliOptions = cliOptions.Value; TemplateInfoProvider = templateInfoProvider; }
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); } }
public LocalDistributedEventBus( ILocalEventBus localEventBus, IHybridServiceScopeFactory serviceScopeFactory, IOptions <DistributedEventBusOptions> distributedEventBusOptions) { _localEventBus = localEventBus; ServiceScopeFactory = serviceScopeFactory; DistributedEventBusOptions = distributedEventBusOptions.Value; Subscribe(distributedEventBusOptions.Value.Handlers); }
public AbpCorsPolicyService( IDistributedCache <AllowedCorsOriginsCacheItem> cache, IHybridServiceScopeFactory hybridServiceScopeFactory, IOptions <IdentityServerOptions> options) { Cache = cache; HybridServiceScopeFactory = hybridServiceScopeFactory; Options = options.Value; Logger = NullLogger <AbpCorsPolicyService> .Instance; }
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); }
public CliService( ICommandLineArgumentParser commandLineArgumentParser, ICommandSelector commandSelector, IHybridServiceScopeFactory serviceScopeFactory) { CommandLineArgumentParser = commandLineArgumentParser; CommandSelector = commandSelector; ServiceScopeFactory = serviceScopeFactory; Logger = NullLogger <CliService> .Instance; }
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; }
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; }
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); } }
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; }
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>(); }
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); }
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); }
public ObjectValidator(IOptions <RocketValidationOptions> options, IHybridServiceScopeFactory serviceScopeFactory) { ServiceScopeFactory = serviceScopeFactory; Options = options.Value; }
public GenerateProxyCommand( IOptions <AbpCliServiceProxyOptions> serviceProxyOptions, IHybridServiceScopeFactory serviceScopeFactory) : base(serviceProxyOptions, serviceScopeFactory) { }
public LocalEventBus(IOptions <EventBusOptions> options, IHybridServiceScopeFactory serviceScopeFactory) : base(options, serviceScopeFactory) { Logger = NullLogger <LocalEventBus> .Instance; }
/// <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; }
/// <summary> /// 初始化一个<see cref="PassThroughEventBus"/>类型的新实例 /// </summary> public PassThroughEventBus(IHybridServiceScopeFactory serviceScopeFactory, IServiceProvider serviceProvider) : base(serviceScopeFactory, serviceProvider) { }
protected EventBusBase(IHybridServiceScopeFactory serviceScopeFactory) { ServiceScopeFactory = serviceScopeFactory; }
public IocEventHandlerFactory(IHybridServiceScopeFactory scopeFactory, Type handlerType) { HandlerType = handlerType; ServiceScope = scopeFactory.CreateScope(); }
public LdapManager(IOptions <RocketLdapOptions> ldapSettingsOptions, IHybridServiceScopeFactory hybridServiceScopeFactory) { _hybridServiceScopeFactory = hybridServiceScopeFactory; _ldapOptions = ldapSettingsOptions.Value; _searchBase = _ldapOptions.SearchBase; }
public IocEventHandlerFactory(IHybridServiceScopeFactory scopeFactory, Type handlerType) { ScopeFactory = scopeFactory; HandlerType = handlerType; }
public TransientEventHandlerFactory(IHybridServiceScopeFactory serviceScopeFactory) : base(serviceScopeFactory, typeof(THandler)) { }
public PageToolbarManager( IHybridServiceScopeFactory serviceScopeFactory) { ServiceScopeFactory = serviceScopeFactory; }
/// <summary> /// /// </summary> /// <param name="serviceScopeFactory"></param> public ExceptionNotifier(IHybridServiceScopeFactory serviceScopeFactory) { ServiceScopeFactory = Check.NotNull(serviceScopeFactory, nameof(serviceScopeFactory)); Logger = NullLogger <ExceptionNotifier> .Instance; }