Welcome to the Microsoft Q&A (Preview) platform. Happy to answer your questions.
Generics on interfaces are not supported for remoting calls. The states would be specific to Actor types and you would be interacting with them in that Actor type’s methods using the StateManager APIs.
You could do something as in below conde snippet:
public class ActorBaseClass : Actor
{
public ActorBaseClass(ActorService actorService, ActorId actorId)
: base(actorService, actorId)
{
}
protected Task GetStateAsync(string stateName, CancellationToken cancellationToken)
{
return this.StateManager.GetStateAsync(stateName, cancellationToken);
}
protected Task AddStateAsync(string stateName, T value, CancellationToken cancellationToken)
{
return this.StateManager.AddStateAsync(stateName, value, cancellationToken);
}
}
internal class UserActor : ActorBaseClass, IUserActor
{
public UserActor(ActorService actorService, ActorId actorId)
: base(actorService, actorId)
{
}
async Task IUserActor.GetCountAsync(CancellationToken cancellationToken)
{
var state = await this.GetStateAsync("count", cancellationToken);
return state.Count;
}
Task IUserActor.SetCountAsync(int count, CancellationToken cancellationToken)
{
var userState = new UserActorState();
userState.Count = count;
return this.StateManager.AddStateAsync("count", userState, cancellationToken);
}
}
public class UserActorState : ActorBaseState
{
public int Count { get; set; }
}
public class ActorBaseState
{
}