public SerializableVersionStamp(VersionStamp versionStamp) { using (var memoryStream = new MemoryStream()) { using (var objectWriter = new ObjectWriter(memoryStream)) { versionStamp.WriteTo(objectWriter); } _bytes = memoryStream.ToArray(); } }
private bool TrySaveIdentifierSetVersion( EsentStorage.IdentifierLocationTableAccessor accessor, EsentStorage.Key key, VersionStamp version) { int identifierId; if (!TryGetIdentifierSetVersionId(out identifierId)) { return(false); } accessor.PrepareBatchOneInsert(); using (var stream = accessor.GetWriteStream(key, identifierId)) using (var writer = new ObjectWriter(stream)) { version.WriteTo(writer); } accessor.FinishBatchOneInsert(); return(true); }
private static async Task WriteToVersionAsync( IPersistentStorage storage, string keyName, VersionStamp projectVersion, VersionStamp semanticVersion, CancellationToken cancellationToken) { using (var stream = SerializableBytes.CreateWritableStream()) using (var writer = new ObjectWriter(stream, cancellationToken: cancellationToken)) { writer.WriteInt32(SerializationFormat); projectVersion.WriteTo(writer); semanticVersion.WriteTo(writer); stream.Position = 0; await storage.WriteStreamAsync(keyName, stream, cancellationToken).ConfigureAwait(false); } }
private bool TrySaveIdentifierSetVersion( EsentStorage.IdentifierLocationTableAccessor accessor, EsentStorage.Key key, VersionStamp version) { if (!TryGetIdentifierSetVersionId(out var identifierId)) { return false; } accessor.PrepareBatchOneInsert(); using (var stream = accessor.GetWriteStream(key, identifierId)) using (var writer = new ObjectWriter(stream)) { version.WriteTo(writer); } accessor.FinishBatchOneInsert(); return true; }
protected override void WriteTo(Stream stream, AnalysisData data, CancellationToken cancellationToken) { using (var writer = new ObjectWriter(stream, cancellationToken: cancellationToken)) { writer.WriteInt32(FormatVersion); _version.WriteTo(writer); data.TextVersion.WriteTo(writer); data.DataVersion.WriteTo(writer); writer.WriteInt32(data.Items.Length); foreach (var item in data.Items) { cancellationToken.ThrowIfCancellationRequested(); writer.WriteString(item.Id); writer.WriteString(item.Category); writer.WriteString(item.Message); writer.WriteString(item.MessageFormat); writer.WriteString(item.Title); writer.WriteString(item.Description); writer.WriteString(item.HelpLink); writer.WriteInt32((int)item.Severity); writer.WriteInt32((int)item.DefaultSeverity); writer.WriteBoolean(item.IsEnabledByDefault); writer.WriteInt32(item.WarningLevel); if (item.HasTextSpan) { // document state writer.WriteInt32(item.TextSpan.Start); writer.WriteInt32(item.TextSpan.Length); } else { // project state writer.WriteInt32(0); writer.WriteInt32(0); } writer.WriteString(item.OriginalFilePath); writer.WriteInt32(item.OriginalStartLine); writer.WriteInt32(item.OriginalStartColumn); writer.WriteInt32(item.OriginalEndLine); writer.WriteInt32(item.OriginalEndColumn); writer.WriteString(item.MappedFilePath); writer.WriteInt32(item.MappedStartLine); writer.WriteInt32(item.MappedStartColumn); writer.WriteInt32(item.MappedEndLine); writer.WriteInt32(item.MappedEndColumn); writer.WriteInt32(item.CustomTags.Count); foreach (var tag in item.CustomTags) { writer.WriteString(tag); } } } }