public void Insert <TEntity>(FileSystemConnectionContext connectionContext, TEntity model) where TEntity : DataEvent { var fileTypeMarker = model is Snapshot ? "snapshot" : "event"; var fullName = Path.Combine(connectionContext.DataRoot, $"{fileTypeMarker}--{model.ContractName}--{model.Id}.json"); var contents = JsonConvert.SerializeObject(model, Formatting.Indented); _fileSystem.CreateDirectoryIfItDoesntExist(connectionContext.DataRoot); _fileSystem.WriteAllText(fullName, contents); }