コード例 #1
0
        public Installer()
        {
            InitializeComponent();



            Container container = ContainerConfigura();

            RegistrarServicosPrefeitura.Initialize(container);

            JobStorage.Current = new MySqlStorage("GerenciadorCrawler");

            var activator = new SimpleInjectorJobActivator(container);

            _server = new BackgroundJobServer(new BackgroundJobServerOptions
            {
                Activator  = activator,
                ServerName = "Monitor Serviço Nota Fiscal"
            }, JobStorage.Current);



            var recurringJobs = AppDomain.CurrentDomain.GetAssemblies()
                                .SelectMany(a => a.GetTypes())
                                .Where(
                type =>
                typeof(IRecurringJob).IsAssignableFrom(type) &&
                !type.IsAbstract &&
                !type.IsGenericTypeDefinition &&
                !type.IsInterface);

            container.RegisterCollection <IRecurringJob>(recurringJobs);

            container.Verify();
        }
 public void ActivateJobCallsSimpleInjector()
 {
     var theJob = new TestJob();
     container.RegisterSingle<TestJob>(theJob);
     var activator = new SimpleInjectorJobActivator(container);
     var result = activator.ActivateJob(typeof(TestJob));
     Assert.AreEqual(theJob, result);
 }
コード例 #3
0
        public void ActivateJobCallsSimpleInjector()
        {
            var theJob = new TestJob();

            container.RegisterInstance <TestJob>(theJob);
            var activator = new SimpleInjectorJobActivator(container);
            var result    = activator.ActivateJob(typeof(TestJob));

            Assert.AreEqual(theJob, result);
        }
コード例 #4
0
        public void ConfigureServices(IServiceCollection services)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables();

            Configuration = builder.Build();

            var connectionString = Configuration.GetConnectionString("DatabaseContext");

            var simpleInjector = new SimpleInjectorJobActivator(Container);

            services.AddHangfire(config => config.UseSqlServerStorage(connectionString)
                                 .UseActivator(simpleInjector)
                                 .UseFilter(new SimpleInjectorAsyncScopeFilterAttribute(Container)));

            services.IntegrateSimpleInjector(Container);
        }
 public void CtorThrowsAnExceptionWhenContainerIsNull()
 {
     // ReSharper disable once UnusedVariable
     var activator = new SimpleInjectorJobActivator(container);
 }
コード例 #6
0
 public void CtorThrowsAnExceptionWhenContainerIsNull()
 {
     // ReSharper disable once UnusedVariable
     var activator = new SimpleInjectorJobActivator(null);
 }