【发布时间】:2017-04-19 21:35:27
【问题描述】:
我有一个带有 hangfire 和服务堆栈服务的控制台应用程序。 Hangfire 有自己的 IOC 适配器实现,它已集成到 Funq 适配器中。我正在尝试使用 IGatewayService 来调用 inproc 服务。
网关始终为空。
public class Tests
{
public IServiceGateway gateway { get; set; }
public Tests()
{
gateway = HostContext.TryResolve<IServiceGateway>(); //tried this along with every type of registration
}
public void Test3() {
// I want to use gateway here to call an inproc service
}
}
我试过了:
Container.Register<IServiceGatewayFactory>(x => new TestServiceGatewayFactory())
.ReusedWithin(ReuseScope.None);
Container.Register<Tests>(new Tests() { gateway = Container.Resolve<IServiceGateway>() });
还有一些其他非 funq 适配器和网关总是为空。我可以在寄存器new TestServiceGateway() 中创建网关,但它需要IRequest。如果我在那里传递 null 它也不会工作。
hangfire 调用很简单:
RecurringJob.AddOrUpdate<Tests>((t) => t.Test3(), Cron.Yearly(12, 12));
【问题讨论】:
标签: servicestack funq