IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IKVM.Tools.Core.Diagnostics.StreamDiagnosticChannel Class Reference

Implementation of IDiagnosticChannel that writes encoded text to a PipeWriter. More...

Inheritance diagram for IKVM.Tools.Core.Diagnostics.StreamDiagnosticChannel:
IKVM.Tools.Core.Diagnostics.IDiagnosticChannel

Public Member Functions

 StreamDiagnosticChannel (Stream stream, Encoding encoding, bool leaveOpen=true)
 Initializes a new instance.
 
void Dispose ()
 Disposes of the instance.
 

Properties

IDiagnosticChannelWriter Writer [get]
 Gets the writer that allows you to enqueue data to the channel.
 
Encoding Encoding [get]
 Gets the native encoding of the channel if the channel expects text.
 
- Properties inherited from IKVM.Tools.Core.Diagnostics.IDiagnosticChannel

Detailed Description

Implementation of IDiagnosticChannel that writes encoded text to a PipeWriter.

Definition at line 12 of file StreamDiagnosticChannel.cs.

Constructor & Destructor Documentation

◆ StreamDiagnosticChannel()

IKVM.Tools.Core.Diagnostics.StreamDiagnosticChannel.StreamDiagnosticChannel ( Stream stream,
Encoding encoding,
bool leaveOpen = true )

Initializes a new instance.

Parameters
stream
encoding
leaveOpen

Definition at line 26 of file StreamDiagnosticChannel.cs.

27 {
28 _stream = stream ?? throw new ArgumentNullException(nameof(stream));
29 _pipe = PipeWriter.Create(_stream, new StreamPipeWriterOptions(leaveOpen: leaveOpen));
30 _writer = new AsyncDiagnosticChannelWriter(_pipe);
31 _encoding = encoding ?? throw new ArgumentNullException(nameof(encoding));
32 }

Member Function Documentation

◆ Dispose()

void IKVM.Tools.Core.Diagnostics.StreamDiagnosticChannel.Dispose ( )

Disposes of the instance.

Definition at line 43 of file StreamDiagnosticChannel.cs.

44 {
45 // dispose the writer, which causes the background writer to terminate and releases any buffers, but does not close the pipe
46 _writer.Dispose();
47
48 // flush and close the pipe, which should close the stream if requested
49 _pipe.FlushAsync().AsTask().GetAwaiter().GetResult();
50 _pipe.Complete();
51 }

Property Documentation

◆ Encoding

Encoding IKVM.Tools.Core.Diagnostics.StreamDiagnosticChannel.Encoding
get

Gets the native encoding of the channel if the channel expects text.

Implements IKVM.Tools.Core.Diagnostics.IDiagnosticChannel.

Definition at line 38 of file StreamDiagnosticChannel.cs.

◆ Writer

IDiagnosticChannelWriter IKVM.Tools.Core.Diagnostics.StreamDiagnosticChannel.Writer
get

Gets the writer that allows you to enqueue data to the channel.

Implements IKVM.Tools.Core.Diagnostics.IDiagnosticChannel.

Definition at line 35 of file StreamDiagnosticChannel.cs.


The documentation for this class was generated from the following file: