如何从 ServiceInstanceListener 构造函数外部访问 StatelessServiceContext 实例
How do you access the StatelessServiceContext instance from outside the ServiceInstanceListener constructor
我在 Azure Service Fabric Web API 项目中有以下代码:
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return new ServiceInstanceListener[]
{
new ServiceInstanceListener(serviceContext => //rest ommitted for brevity
}
}
有没有办法可以从 ServiceInstanceListener
构造函数外部访问 serviceContext
?
我希望可能会有类似 StatelessServiceContext statelessServiceContext = StatelessServiceContext.GetCurrentContext();
的内容
我想要这样做的原因是在我不使用 ServiceInstanceListener
构造函数的方法中访问 StatelessServiceContext.CodePackageActivationContext
属性。
有关详细信息,请参阅 。
在服务中使用 this.Context
。
我在 Azure Service Fabric Web API 项目中有以下代码:
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return new ServiceInstanceListener[]
{
new ServiceInstanceListener(serviceContext => //rest ommitted for brevity
}
}
有没有办法可以从 ServiceInstanceListener
构造函数外部访问 serviceContext
?
我希望可能会有类似 StatelessServiceContext statelessServiceContext = StatelessServiceContext.GetCurrentContext();
我想要这样做的原因是在我不使用 ServiceInstanceListener
构造函数的方法中访问 StatelessServiceContext.CodePackageActivationContext
属性。
有关详细信息,请参阅
在服务中使用 this.Context
。