This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IStateHolderGrain<T> : IGrainWithGuidKey | |
{ | |
Task<T> GetItem(); | |
Task<T> SetItem(T obj); | |
} | |
public class StateHolder<T> | |
{ | |
public StateHolder() : this(default(T)) | |
{ | |
} | |
public StateHolder(T value) | |
{ | |
Value = value; | |
} | |
public T Value { get; set; } | |
} | |
public abstract class StateHolderGrain<T> : Grain<StateHolder<T>>, | |
IStateHolderGrain<T> | |
{ | |
public Task<T> GetItem() | |
{ | |
return Task.FromResult(State.Value); | |
} | |
public async Task<T> SetItem(T item) | |
{ | |
State.Value = item; | |
await WriteStateAsync(); | |
return State.Value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment