Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cocowalla/hangfire.structuremap
Hangfire background job activator based on the StructureMap IoC container
https://github.com/cocowalla/hangfire.structuremap
dependency-injection hangfire ioc structuremap
Last synced: 16 days ago
JSON representation
Hangfire background job activator based on the StructureMap IoC container
- Host: GitHub
- URL: https://github.com/cocowalla/hangfire.structuremap
- Owner: cocowalla
- License: apache-2.0
- Created: 2014-11-14T21:46:23.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2022-06-28T14:01:52.000Z (over 2 years ago)
- Last Synced: 2024-12-06T20:15:34.599Z (16 days ago)
- Topics: dependency-injection, hangfire, ioc, structuremap
- Language: C#
- Size: 706 KB
- Stars: 17
- Watchers: 4
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Hangfire.StructureMap
=====================[![Windows Build Status](https://img.shields.io/appveyor/ci/cocowalla/hangfire-structuremap.svg?label=Windows%20Build)](https://ci.appveyor.com/project/cocowalla/hangfire-structuremap)
[![Linux Build status](https://img.shields.io/travis/cocowalla/Hangfire.StructureMap.svg?label=Linux%20Build)](https://travis-ci.org/cocowalla/Hangfire.StructureMap)
[![NuGet](https://img.shields.io/nuget/v/Hangfire.StructureMap.svg)](https://www.nuget.org/packages/Hangfire.StructureMap)This package provides [StructureMap](http://structuremap.github.io/) support for [Hangfire](http://hangfire.io), allowing nested StructureMap containers to resolve job type instances and their dependencies, and to manage the lifetime of resolved instances.
Getting started
---------------Install the [Hangfire.StructureMap](https://www.nuget.org/packages/Hangfire.StructureMap) package from NuGet:
```powershell
Install-Package Hangfire.StructureMap
```To configure Hangfire to use StructureMap, configure your container and call the `IGlobalConfiguration` extension method, `UseStructureMapActivator`:
```csharp
var container = new Container();
// container.Configure...GlobalConfiguration.Configuration.UseStructureMapActivator(container);
```After configuration, when jobs are started a StructureMap-based implementation of the `JobActivator` class is used to resolve job type instances and all of their dependencies.
Object Lifecycles
-----------------*Hangfire.StructureMap* doesn't rely on a specific object lifecycle - you can configure your dependencies as `Singleton`, `ContainerScoped`, `Transient`, `AlwaysUnique` or `ThreadLocal` as normal.
*Hangfire.StructureMap* creates a [*nested container*](http://structuremap.github.io/the-container/nested-containers/) for each job execution, so using `ContainerScoped` will scope dependency lifetimes to that of the job.
```csharp
container.For().ContainerScoped().Use();
```The nested container is disposed when jobs ends, and all dependencies that implement the `IDisposable` interface are also automatically disposed (`Singleton` scoped instances are of course an exception).