예제 #1
0
            /// <summary>
            /// this is callback from remote host side to get asset associated with checksum from VS.
            /// </summary>
            public async Task RequestAssetAsync(int sessionId, byte[][] checksums, string streamName)
            {
                try
                {
                    Contract.ThrowIfFalse(_owner._currentSessionId == sessionId);

                    using (Logger.LogBlock(FunctionId.JsonRpcSession_RequestAssetAsync, streamName, _source.Token))
                        using (var stream = await DirectStream.GetAsync(streamName, _source.Token).ConfigureAwait(false))
                        {
                            using (var writer = new StreamObjectWriter(stream))
                            {
                                writer.WriteInt32(sessionId);

                                await WriteAssetAsync(writer, checksums).ConfigureAwait(false);
                            }

                            await stream.FlushAsync(_source.Token).ConfigureAwait(false);
                        }
                }
                catch (IOException)
                {
                    // remote host side is cancelled (client stream connection is closed)
                    // can happen if pinned solution scope is disposed
                }
                catch (OperationCanceledException)
                {
                    // rpc connection is closed.
                    // can happen if pinned solution scope is disposed
                }
            }
예제 #2
0
            protected override void WriteTo(Stream stream, Data data, CancellationToken cancellationToken)
            {
                using (var writer = new StreamObjectWriter(stream, cancellationToken: cancellationToken))
                {
                    writer.WriteString(FormatVersion);
                    data.TextVersion.WriteTo(writer);
                    data.SyntaxVersion.WriteTo(writer);

                    writer.WriteInt32(data.Items.Length);

                    foreach (var item in data.Items.OfType <TodoItem>())
                    {
                        cancellationToken.ThrowIfCancellationRequested();

                        writer.WriteInt32(item.Priority);
                        writer.WriteString(item.Message);

                        writer.WriteString(item.OriginalFilePath);
                        writer.WriteInt32(item.OriginalLine);
                        writer.WriteInt32(item.OriginalColumn);

                        writer.WriteString(item.MappedFilePath);
                        writer.WriteInt32(item.MappedLine);
                        writer.WriteInt32(item.MappedColumn);
                    }
                }
            }
예제 #3
0
        private static async Task WriteToVersionAsync(
            IPersistentStorage storage, string keyName, VersionStamp projectVersion, VersionStamp semanticVersion, CancellationToken cancellationToken)
        {
            using (var stream = SerializableBytes.CreateWritableStream())
                using (var writer = new StreamObjectWriter(stream, cancellationToken: cancellationToken))
                {
                    writer.WriteInt32(SerializationFormat);
                    projectVersion.WriteTo(writer);
                    semanticVersion.WriteTo(writer);

                    stream.Position = 0;
                    await storage.WriteStreamAsync(keyName, stream, cancellationToken).ConfigureAwait(false);
                }
        }