Exemple #1
2
 public DelegateService(IServiceScopeFactory scopeFactory, Func<IServiceProvider, CancellationToken, Task> @delegate)
 {
     this.scopeFactory = scopeFactory;
     this.@delegate = @delegate;
 }
        public RequestServicesContainerMiddleware(RequestDelegate next, IServiceScopeFactory scopeFactory)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }
            if (scopeFactory == null)
            {
                throw new ArgumentNullException(nameof(scopeFactory));
            }

            _scopeFactory = scopeFactory;
            _next = next;
        }
        public RequestServicesFeature(IServiceScopeFactory scopeFactory)
        {
            if (scopeFactory == null)
            {
                throw new ArgumentNullException(nameof(scopeFactory));
            }

            _scopeFactory = scopeFactory;
        }
 public DebugInitializer(
     ILoggerFactory logger,
     IServiceProvider serviceProvider,
     UserManager<ApplicationUser> userManager,
     RoleManager<ApplicationRole> roleManager)
 {
     _logger = logger.CreateLogger(nameof(DebugInitializer));
     _serviceProvider = serviceProvider;
     _scopeFactory = _serviceProvider.GetRequiredService<IServiceScopeFactory>();
     _userManager = userManager;
     _roleManager = roleManager;
 }
        private bool disposedValue = false; // To detect redundant calls

        #endregion Fields

        #region Constructors

        public RequestServicesContainer(
            HttpContext context,
            IServiceScopeFactory scopeFactory,
            IServiceProvider appServiceProvider)
        {
            if (scopeFactory == null)
            {
                throw new ArgumentNullException(nameof(scopeFactory));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            Context = context;
            PriorAppServices = context.ApplicationServices;
            PriorRequestServices = context.RequestServices;

            // Begin the scope
            Scope = scopeFactory.CreateScope();

            Context.ApplicationServices = appServiceProvider;
            Context.RequestServices = Scope.ServiceProvider;
        }
        public GoogleDriveService(ILogger <GoogleDriveService> logger, IConfiguration configuration, IServiceScopeFactory scopeFactory)
        {
            _logger = logger;

            ScopeFactory  = scopeFactory;
            Configuration = configuration;

            using (var stream = new FileStream(Configuration["GoogleDriveTokenPath"], FileMode.Open, FileAccess.Read))
            {
                string credPath = configuration["GoogleDriveOutputCredentialPath"];
                Credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    Scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, true)).Result;

                _logger.LogInformation("Google Credential file saved to {0}", credPath);
            }

            DriveService = new DriveService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = Credential,
                ApplicationName       = ApplicationName
            });

            UploadFilesInfo();
        }
Exemple #7
0
 public JobTrackerService(IServiceScopeFactory scopeFactory, UserLogger userLogger)
 {
     this.scopeFactory = scopeFactory;
     this.userLogger   = userLogger;
 }
Exemple #8
0
 public ProviderUserRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper)
     : base(serviceScopeFactory, mapper, (DatabaseContext context) => context.ProviderUsers)
 {
 }
Exemple #9
0
 public CreateTransactionHandler(ITransactionExecuteSender transactionExecuteSender, IServiceScopeFactory serviceScopeFactory)
 {
     _transactionExecuteSender = transactionExecuteSender;
     _serviceScopeFactory      = serviceScopeFactory;
 }
 public ScheduledProcessor(IServiceScopeFactory serviceScopeFactory) : base(serviceScopeFactory)
 {
     _schedule = CrontabSchedule.Parse(Schedule);
     _nextRun  = _schedule.GetNextOccurrence(DateTime.Now);
 }
Exemple #11
0
 public TweetsKQueryStreamSet(IServiceScopeFactory serviceScopeFactory, QueryContext queryContext) : base(serviceScopeFactory, queryContext)
 {
 }
 public NotificationJob(IServiceScopeFactory serviceScopeFactory)
 {
     _serviceScopeFactory = serviceScopeFactory;
 }
Exemple #13
0
 public LineBotApp(LineMessagingClient lineMessagingClient, jafleetContext context, ToolsContext toolsContext, IServiceScopeFactory serviceScopeFactory)
 {
     this.messagingClient = lineMessagingClient;
     _context             = context;
     _tContext            = toolsContext;
     _services            = serviceScopeFactory;
 }
Exemple #14
0
 internal Consumer(BusConnection connection, IBusLogger logger, IRetryBehavior retryBehavior, IServiceScopeFactory scopeFactory, ConsumerOptions <T> options)
 {
     _options       = options ?? throw new ArgumentNullException(nameof(options));
     _connection    = connection ?? throw new ArgumentNullException(nameof(connection));
     _logger        = logger;
     _retryBehavior = retryBehavior ?? throw new ArgumentNullException(nameof(retryBehavior));
     _scopeFactory  = scopeFactory ?? throw new ArgumentNullException(nameof(scopeFactory));
     _tasks         = new Tasks(_options.ConsumerMaxParallelTasks);
     _channel       = connection.ConsumerConnection.CreateModel();
     _channel.BasicQos(0, options.PrefetchCount, false);
     DeclareAndBind();
     _consumerTag = _channel.BasicConsume(_options.Queue.Name.Value, false, this);
 }
Exemple #15
0
        /// <summary>
        /// 创建一个作用域范围
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="handler"></param>
        /// <param name="scopeFactory"></param>
        /// <returns></returns>
        public static async Task <T> CreateRef <T>(Func <IServiceScopeFactory, IServiceScope, Task <T> > handler, IServiceScopeFactory scopeFactory = default)
        {
            // 禁止空调用
            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }

            // 创建作用域
            using var scoped = CreateScope(ref scopeFactory);

            // 执行方法
            var result = await handler.Invoke(scopeFactory, scoped);

            return(result);
        }
Exemple #16
0
        /// <summary>
        /// 创建一个作用域范围
        /// </summary>
        /// <param name="handler"></param>
        /// <param name="scopeFactory"></param>
        public static void Create(Action <IServiceScopeFactory, IServiceScope> handler, IServiceScopeFactory scopeFactory = default)
        {
            // 禁止空调用
            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }

            // 创建作用域
            using var scoped = CreateScope(ref scopeFactory);

            // 执行方法
            handler.Invoke(scopeFactory, scoped);
        }
Exemple #17
0
        /// <summary>
        /// 创建一个工作单元作用域
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="handler"></param>
        /// <param name="scopeFactory"></param>
        /// <returns></returns>
        public static async Task <T> CreateUowRef <T>(Func <IServiceScopeFactory, IServiceScope, Task <T> > handler, IServiceScopeFactory scopeFactory = default)
        {
            // 禁止空调用
            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }

            // 创建作用域
            using var scoped = CreateScope(ref scopeFactory);

            // 创建一个数据库上下文池
            var dbContextPool = scoped.ServiceProvider.GetService <IDbContextPool>();
            var result        = await handler.Invoke(scopeFactory, scoped);

            dbContextPool.SavePoolNow();

            return(result);
        }
Exemple #18
0
        /// <summary>
        /// 创建一个工作单元作用域
        /// </summary>
        /// <param name="handler"></param>
        /// <param name="scopeFactory"></param>
        public static void CreateUow(Action <IServiceScopeFactory, IServiceScope> handler, IServiceScopeFactory scopeFactory = default)
        {
            // 禁止空调用
            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }

            // 创建作用域
            using var scoped = CreateScope(ref scopeFactory);

            // 创建一个数据库上下文池
            var dbContextPool = scoped.ServiceProvider.GetService <IDbContextPool>();

            handler.Invoke(scopeFactory, scoped);
            dbContextPool.SavePoolNow();
        }
Exemple #19
0
 public SendEmailsTask(IServiceScopeFactory serviceScopeFactory) : base(serviceScopeFactory)
 {
 }
 public BlockHeightTracker(IConfiguration configuration, ILoggerFactory loggerFactory, IServiceScopeFactory scopeFactory, IShareCalculator shareCalculator, IMessenger messenger)
 {
     _configuration   = configuration;
     _logger          = loggerFactory.CreateLogger <BlockHeightTracker>();
     _scopeFactory    = scopeFactory;
     _shareCalculator = shareCalculator;
     _messenger       = messenger;
 }
        // JobType = "Oqtane.Infrastructure.NotificationJob, Oqtane.Server"

        public NotificationJob(IServiceScopeFactory serviceScopeFactory) : base(serviceScopeFactory)
        {
        }
Exemple #22
0
 public RabbitMqMessageBroker(IConnectionFactory connectionFactory, IServiceScopeFactory serviceScopeFactory)
 {
     _connection          = connectionFactory.CreateConnection();
     _subscriptionChannel = _connection.CreateModel();
     _serviceScopeFactory = serviceScopeFactory;
 }
 public JwtMiddleware(RequestDelegate next, IServiceScopeFactory factory)
 {
     _scopeFactory = factory;
     _next         = next;
 }
        public void CreateObjectsTest()
        {
            IServiceCollection   pool     = Implementation.CreateServiceCollection();
            IServiceScopeFactory factory  = Implementation.CreateServiceScopeFactory(pool);
            IServiceProvider     services = factory.CreateScope().ServiceProvider;

            try
            {
                object staticobj = services.CreateInstance(typeof(StaticObject), 10) as StaticObject;
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
            }

            try
            {
                IFake fakeobj = services.CreateInstance <IFake>();
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
            }

            try
            {
                AbstractObject absobj = services.CreateInstance <AbstractObject>();
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
            }

            try
            {
                PrivateObject privateobj = services.CreateInstance <PrivateObject>(5);
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
            }

            try
            {
                EnumTest enumobj = services.CreateInstance <EnumTest>();
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
            }

            try
            {
                DelegateTest delegateobj = services.CreateInstance <DelegateTest>();
                Assert.Fail();
            }
            catch (Exception)
            {
            }

            GenericObject <int> intgeneric = services.CreateInstance <GenericObject <int> >(10);

            Assert.AreEqual(10, intgeneric.Value);

            GenericObject <double> doublegeneric = services.CreateInstance <GenericObject <double> >();

            Assert.AreEqual(0, doublegeneric.Value);

            try
            {
                int[] intarray = services.CreateInstance <int[]>(10);
                Assert.Fail();
            }
            catch (InvalidOperationException)
            {
            }

            int inttest = services.CreateInstance <int>(5);

            Assert.AreEqual(5, inttest);

            StructObject structobj = services.CreateInstance <StructObject>(5);

            Assert.AreEqual(5, structobj.Value);
        }
Exemple #25
0
 public HarbourTask(ILogger <HarbourTask> logger, IServiceScopeFactory scopeFactory)
 {
     this.logger       = logger;
     this.scopeFactory = scopeFactory;
 }
 public SortService(IServiceScopeFactory serviceScopeFactory, ILogger <SortService> logger)
 {
     _serviceScopeFactory = serviceScopeFactory;
     _logger = logger;
 }
Exemple #27
0
 public TestGrainStorageConvention(
     IOptions <GrainStorageConventionOptions> options, IServiceScopeFactory serviceScopeFactory) : base(options,
                                                                                                        serviceScopeFactory)
 {
 }
Exemple #28
0
 public void SetServiceProvider(IServiceScopeFactory serviceScopeFactory)
 {
     this.serviceScopeFactory = serviceScopeFactory;
 }
Exemple #29
0
 public ProducerService(IServiceScopeFactory scopeFactory, ILogger <ProducerService> logger)
 {
     this.scopeFactory = scopeFactory;
     this.logger       = logger;
 }
Exemple #30
0
 public static void RegisterJobs(IServiceScopeFactory serviceScopeFactory)
 {
     RecurringJob.AddOrUpdate <IElasticReorganizer>(a => a.StartReocganizationAsync(),
                                                    "0 0 * * *", //this cron expressions means execute at 00:00 am. more info: "https://crontab.guru/#0_0_*_*_*"
                                                    TimeZoneInfo.Utc);
 }
 public CommandDispatcher(IServiceScopeFactory serviceScopeFactory, ZaminServices zaminServices)
 {
     _serviceFactory = serviceScopeFactory;
     _zaminServices  = zaminServices;
 }
 public ChangesOfPendingSpodu(IServiceScopeFactory serviceScopeFactory
                              ) :
     base(serviceScopeFactory)
 {
     _serviceScopeFactory = serviceScopeFactory;
 }
 public UpdateGraphsService(ILogger <PruneDatabaseService> logger, IServiceScopeFactory scopeFactory)
 {
     _logger       = logger;
     _scopeFactory = scopeFactory;
 }
Exemple #34
0
 public CacheHostedService(IServiceScopeFactory scopeFactory)
 {
     _scopeFactory = scopeFactory ?? throw new ArgumentNullException(nameof(scopeFactory));
 }
 public AspNetCoreJobActivator([NotNull] IServiceScopeFactory serviceScopeFactory)
 {
     if (serviceScopeFactory == null) throw new ArgumentNullException(nameof(serviceScopeFactory));
     _serviceScopeFactory = serviceScopeFactory;
 }
Exemple #36
0
 public AnotherSampleServiceImplementation(IServiceScopeFactory scopeFactory)
 {
     _scopeFactory = scopeFactory;
 }