Example #1
0
        /// <summary>
        /// Tells global configuration to use the specified StructureMap container as a job activator.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="serviceProvider">The root service provider.</param>
        /// <returns>An instance of <see cref="ServiceProviderJobActivator"/>.</returns>
        /// <exception cref="System.ArgumentNullException">configuration or container.
        /// </exception>
        public static IGlobalConfiguration <ServiceProviderJobActivator> UseServiceProviderActivator(this IGlobalConfiguration configuration, IServiceProvider serviceProvider)
        {
            Guard.NotNull(nameof(configuration), configuration);
            Guard.NotNull(nameof(serviceProvider), serviceProvider);

            return(configuration.UseActivator(new ServiceProviderJobActivator(serviceProvider)));
        }
        /// <summary>
        /// Configures the given <see cref="IDependencyResolver"/> as the default <see cref="JobActivator"/> for resolving job dependencies.
        /// </summary>
        /// <param name="configuration">The global configuration.</param>
        /// <param name="container">The dependency resolver.</param>
        /// <returns>The <see cref="IGlobalConfiguration{StashboxJobActivator}"/> instance which uses the given Stashbox container to resolve job dependencies.</returns>
        /// <exception cref="ArgumentNullException">When <paramref name="container"/> is null.</exception>
        public static IGlobalConfiguration <StashboxJobActivator> UseStashboxActivator(
            this IGlobalConfiguration configuration,
            IDependencyResolver container)
        {
            Shield.EnsureNotNull(container, nameof(container));

            return(configuration.UseActivator(new StashboxJobActivator(container)));
        }
Example #3
0
        public static IGlobalConfiguration <AutofacJobActivator> UseAutofacActivator(
            [NotNull] this IGlobalConfiguration configuration,
            [NotNull] ILifetimeScope lifetimeScope, bool useTaggedLifetimeScope = true)
        {
            Check.NotNull(configuration, nameof(configuration));
            Check.NotNull(lifetimeScope, nameof(lifetimeScope));

            return(configuration.UseActivator(new AutofacJobActivator(lifetimeScope, useTaggedLifetimeScope)));
        }
Example #4
0
        public static void UseLuigi(this IGlobalConfiguration configuration, IServiceProvider serviceProvider)
        {
            configuration.UseActivator(new LuigiHangfireJobActivator(serviceProvider));
            var jsonSerializerSettings = new JsonSerializerSettings
            {
                TypeNameHandling = TypeNameHandling.All,
            };

            configuration.UseSerializerSettings(jsonSerializerSettings);
        }
Example #5
0
        public static IGlobalConfiguration <JobActivator> UseDefaultActivator(
            [NotNull] this IGlobalConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            return(configuration.UseActivator(new JobActivator()));
        }
Example #6
0
        public static IGlobalConfiguration UseMediatR(this IGlobalConfiguration config, IMediator mediator)
        {
            config.UseActivator(new MediatRJobActivator(mediator));

            config.UseSerializerSettings(new JsonSerializerSettings
            {
                TypeNameHandling = TypeNameHandling.Objects
            });

            return(config);
        }
Example #7
0
        public static IGlobalConfiguration UseMediatR(this IGlobalConfiguration config, IMediator mediator)
        {
            config.UseActivator(new HangfireMediatrActivator(mediator));

            JobHelper.SetSerializerSettings(new JsonSerializerSettings
            {
                TypeNameHandling      = TypeNameHandling.Objects,
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
            });

            return(config);
        }
        /// <summary>
        /// Tells global configuration to use the specified StructureMap container as a job activator.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="container">The container.</param>
        /// <returns>An instance of <see cref="IGlobalConfiguration{StructureMapJobActivator}"/>.</returns>
        /// <exception cref="System.ArgumentNullException">
        /// configuration
        /// or
        /// container
        /// </exception>
        public static IGlobalConfiguration <StructureMapJobActivator> UseStructureMapActivator([NotNull] this IGlobalConfiguration configuration, [NotNull] IContainer container)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            return(configuration.UseActivator(new StructureMapJobActivator(container)));
        }
        /// <summary>
        /// Tells global configuration to use the specified Service Provider container as a job activator.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="serviceProvider">The service provider.</param>
        /// <returns>An instance of <see cref="IGlobalConfiguration{ServiceProviderJobActivator}"/>.</returns>
        /// <exception cref="System.ArgumentNullException">configuration or container</exception>
        public static IGlobalConfiguration <ServiceProviderJobActivator> UseServiceProviderJobActivator([NotNull] this IGlobalConfiguration configuration, [NotNull] IServiceProvider serviceProvider)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            return(configuration.UseActivator(new ServiceProviderJobActivator(serviceProvider)));
        }
        public static IGlobalConfiguration <MEFJobActivator> UseMEFActivator(
            [NotNull] this IGlobalConfiguration configuration, CompositionContainer container)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            return(configuration.UseActivator(new MEFJobActivator(container)));
        }
Example #11
0
        public static IGlobalConfiguration UseNestedContainerActivator(this IGlobalConfiguration This,
                                                                       IContainer container)
        {
            if (This == null)
            {
                throw new ArgumentNullException(nameof(This));
            }
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            return(This.UseActivator(new NestedContainerActivator(container)));
        }
        public static IGlobalConfiguration <UnityJobActivator> UseUnityActivator(
            [NotNull] this IGlobalConfiguration configuration, IUnityContainer container)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            return(configuration.UseActivator(new UnityJobActivator(container)));
        }
        public static IGlobalConfiguration <NinjectJobActivator> UseNinjectActivator(
            [NotNull] this IGlobalConfiguration configuration,
            [NotNull] IKernel kernel)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            if (kernel == null)
            {
                throw new ArgumentNullException("kernel");
            }

            return(configuration.UseActivator(new NinjectJobActivator(kernel)));
        }
Example #14
0
        public static IGlobalConfiguration UseMediatR(this IGlobalConfiguration config, IMediator mediator, DatabaseConnectionFactory getDbConnection)
        {
            config.UseActivator(new MediatRJobActivator(mediator, getDbConnection));

            JobHelper.SetSerializerSettings(new JsonSerializerSettings
            {
                TypeNameHandling = TypeNameHandling.Objects,
            });

            GetDatabaseConnection = getDbConnection;

            CreateMediatRTable();

            return(config);
        }
        public static IGlobalConfiguration <AutofacJobActivator> UseAutofacActivator(
            [NotNull] this IGlobalConfiguration configuration,
            [NotNull] ILifetimeScope lifetimeScope, bool useTaggedLifetimeScope = true)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }
            if (lifetimeScope == null)
            {
                throw new ArgumentNullException(nameof(lifetimeScope));
            }

            return(configuration.UseActivator(new AutofacJobActivator(lifetimeScope, useTaggedLifetimeScope)));
        }
        public static IGlobalConfiguration <AutofacJobActivator> UseAutofacActivator(
            [NotNull] this IGlobalConfiguration configuration,
            [NotNull] ILifetimeScope lifetimeScope)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            if (lifetimeScope == null)
            {
                throw new ArgumentNullException("lifetimeScope");
            }

            return(configuration.UseActivator(new AutofacJobActivator(lifetimeScope)));
        }
        public static IGlobalConfiguration <HangfireJobActivator> UseDIActivator(
            [NotNull] this IGlobalConfiguration configuration,
            [NotNull] IServiceProvider serviceProvider)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            return(configuration.UseActivator(new HangfireJobActivator(serviceProvider)));
        }
        public static IGlobalConfiguration <LightInjectJobActivator> UseLightInjectActivator(
            [NotNull] this IGlobalConfiguration configuration,
            [NotNull] ServiceContainer container)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            return(configuration.UseActivator(new LightInjectJobActivator(container)));
        }
        public static void Configure(IGlobalConfiguration httpConfiguration, IAppBuilder app)
        {
            var container = UnityConfigurator.GetConfiguredContainer();

            httpConfiguration.UseActivator(new ContainerJobActivator(container));

            app.UseHangfireAspNet(GetHangfireServers);

            if (AppSettingsService.Environment.IsDev())
            {
                // If we are in Dev, always allow Hangfire access.
                app.UseHangfireDashboard("/hangfire");
            }
            else
            {
                app.UseHangfireDashboard("/hangfire", new DashboardOptions
                {
                    Authorization = new[] { new InventAppHangfireDashboardAuthorizationFilter() }
                });
            }
        }
 public static IGlobalConfiguration UseMessagePublisherActivator(
     this IGlobalConfiguration configuration,
     IServiceProvider serviceProvider)
 => configuration.UseActivator(
     new ContextAwareJobActivator(serviceProvider.GetService <IServiceScopeFactory>()));
 public static IGlobalConfiguration <AutofacJobActivator> UseAutofacActivator(
     this IGlobalConfiguration configuration,
     ILifetimeScope lifetimeScope, Boolean useTaggedLifetimeScope = true)
 {
     return(configuration.UseActivator(new AutofacJobActivator(lifetimeScope, useTaggedLifetimeScope)));
 }
Example #22
0
        public static IGlobalConfiguration UseExtensionsJobActivator(this IGlobalConfiguration globalConfiguration, IServiceProvider serviceProvider)
        {
            var activator = new ExtensionsJobActivator(serviceProvider);

            return(globalConfiguration.UseActivator(activator));
        }