Skip to content

Instantly share code, notes, and snippets.

@odinserj
Last active August 29, 2015 14:03
Show Gist options
  • Save odinserj/c29b63d0dea623b4f2a0 to your computer and use it in GitHub Desktop.
Save odinserj/c29b63d0dea623b4f2a0 to your computer and use it in GitHub Desktop.
Hangfire job activator based on ServiceStack IoC container
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