Example #1
0
 public async Task SaveAsync(int templateId, Segment segment)
 {
     var fileText = FileSegments.SerializeSegment(segment);
     using (var stream = File.CreateText(_templatePath + $@"\{templateId + TemplateExtension}"))
     {
         await stream.WriteAsync(fileText).ConfigureAwait(false);
     }
 }
Example #2
0
 public async Task<Segment> GetAsync(int templateId)
 {
     if (!File.Exists(_templatePath + $@"\{templateId + TemplateExtension}")) return null;
     
     using (var stream = File.OpenText(_templatePath + $@"\{templateId + TemplateExtension}"))
     {
         var fileText = await stream.ReadToEndAsync().ConfigureAwait(false);
         return FileSegments.DeserializeSegment(fileText);
     }
 }