Last active
August 29, 2015 14:03
-
-
Save odinserj/c29b63d0dea623b4f2a0 to your computer and use it in GitHub Desktop.
Hangfire job activator based on ServiceStack IoC container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FuncJobActivator : JobActivator | |
{ | |
private readonly Container _container; | |
public FuncJobActivator(Container container) | |
{ | |
if (container == null) throw new ArgumentNullException("container"); | |
_container = container; | |
} | |
public override object ActivateJob(Type jobType) | |
{ | |
var mi = typeof(Container).GetMethods().FirstOrDefault(m => m.Name == "Resolve"); | |
var resolveRef = mi.MakeGenericMethod(jobType); | |
return resolveRef.Invoke(_container, null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment