I have added WebAPI to my stateful serive and want to access StateManager
from it (from outside of StatefulService
class implementation).
What is the best way to do it?
Currently I am using a small class for this:
internal static class InstanceAccessor
{
internal static StatefulService ActiveInstance { get; set; }
}
And put the value inside RunAsync method of the StatefulService
:
protected override async Task RunAsync(CancellationToken cancellationToken)
{
InstanceAccessor.ActiveInstance = this;
...