protected override async Task SaveAsync(TRoot root, CancellationToken cancellationToken) { Contract.ThrowIfFalse(_storage == null); // Cannot save more than once // tree will be always held alive in memory, but nodes come and go. serialize nodes to storage using var stream = SerializableBytes.CreateWritableStream(); root.SerializeTo(stream, cancellationToken); stream.Position = 0; _storage = _service.LanguageServices.WorkspaceServices.GetService <ITemporaryStorageService>().CreateTemporaryStreamStorage(cancellationToken); await _storage.WriteStreamAsync(stream, cancellationToken).ConfigureAwait(false); }
protected override async Task SaveAsync(TRoot root, CancellationToken cancellationToken) { // tree will be always held alive in memory, but nodes come and go. serialize nodes to storage using (var stream = SerializableBytes.CreateWritableStream()) { root.SerializeTo(stream, cancellationToken); stream.Position = 0; storage = this.service.LanguageServices.WorkspaceServices.GetService <ITemporaryStorageService>().CreateTemporaryStreamStorage(cancellationToken); await storage.WriteStreamAsync(stream, cancellationToken).ConfigureAwait(false); } }