Beispiel #1
0
        public async Task ReadStateAsync(string grainType, Orleans.Runtime.GrainReference grainReference, Orleans.IGrainState grainState)
        {
            var fileInfo = this.GetFileInfo(grainType, grainReference);

            if (!fileInfo.Exists)
            {
                return;
            }

            using (var stream = fileInfo.OpenText())
            {
                var json = await stream.ReadToEndAsync();

                var data = JsonConvert.DeserializeObject <Dictionary <string, object> >(json);
                grainState.SetAll(data);
            }
        }
Beispiel #2
0
        public Task WriteStateAsync(string grainType, Orleans.Runtime.GrainReference grainReference, Orleans.IGrainState grainState)
        {
            var json     = JsonConvert.SerializeObject(grainState.AsDictionary());
            var fileInfo = this.GetFileInfo(grainType, grainReference);

            using (var stream = fileInfo.OpenWrite())
            {
                using (var writer = new StreamWriter(stream))
                {
                    return(writer.WriteAsync(json));
                }
            }
        }
Beispiel #3
0
        public Task ClearStateAsync(string grainType, Orleans.Runtime.GrainReference grainReference, Orleans.IGrainState grainState)
        {
            var fileInfo = this.GetFileInfo(grainType, grainReference);

            fileInfo.Delete();
            return(TaskDone.Done);
        }