IKVM11
11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
FileDiagnosticChannelFactory.cs
Go to the documentation of this file.
1
using
System
;
2
using
System.IO;
3
using
System.Linq;
4
using
System.Text
;
5
6
using
Microsoft.Extensions.DependencyInjection;
7
8
namespace
IKVM.Tools.Core.Diagnostics
9
{
10
14
class
FileDiagnosticChannelFactory
:
IDiagnosticChannelFactory
15
{
16
17
public
const
string
STDOUT
=
"stdout"
;
18
public
const
string
STDERR
=
"stderr"
;
19
25
public
static
IServiceCollection
Add
(IServiceCollection services)
26
{
27
return
services.AddSingleton<
IDiagnosticChannelFactory
,
FileDiagnosticChannelFactory
>();
28
}
29
31
public
IDiagnosticChannel
?
CreateChannel
(
string
spec)
32
{
33
if
(spec is
null
)
34
throw
new
ArgumentNullException(nameof(spec));
35
36
return
spec
switch
37
{
38
"1"
or
STDOUT
=>
new
StreamDiagnosticChannel
(Console.OpenStandardOutput(), Console.OutputEncoding, leaveOpen:
false
),
39
"2"
or
STDERR
=>
new
StreamDiagnosticChannel
(Console.OpenStandardError(), Console.OutputEncoding, leaveOpen:
false
),
40
_ when spec.Contains(Path.DirectorySeparatorChar) =>
new
StreamDiagnosticChannel
(File.OpenWrite(spec), Encoding.UTF8, leaveOpen:
false
),
41
_ =>
null
,
42
};
43
}
44
45
}
46
47
}
IKVM.Tools.Core.Diagnostics.FileDiagnosticChannelFactory
Resolves a "file" diagnostic output value.
Definition
FileDiagnosticChannelFactory.cs:15
IKVM.Tools.Core.Diagnostics.FileDiagnosticChannelFactory.CreateChannel
IDiagnosticChannel? CreateChannel(string spec)
Attempts to parse the channel spec into a IDiagnosticChannel
Definition
FileDiagnosticChannelFactory.cs:31
IKVM.Tools.Core.Diagnostics.FileDiagnosticChannelFactory.STDERR
const string STDERR
Definition
FileDiagnosticChannelFactory.cs:18
IKVM.Tools.Core.Diagnostics.FileDiagnosticChannelFactory.Add
static IServiceCollection Add(IServiceCollection services)
Adds the JSON diagnostic formater to the IServiceCollection.
Definition
FileDiagnosticChannelFactory.cs:25
IKVM.Tools.Core.Diagnostics.FileDiagnosticChannelFactory.STDOUT
const string STDOUT
Definition
FileDiagnosticChannelFactory.cs:17
IKVM.Tools.Core.Diagnostics.StreamDiagnosticChannel
Implementation of IDiagnosticChannel that writes encoded text to a PipeWriter.
Definition
StreamDiagnosticChannel.cs:13
IKVM.Tools.Core.Diagnostics.IDiagnosticChannelFactory
Definition
IDiagnosticChannelFactory.cs:5
IKVM.Tools.Core.Diagnostics.IDiagnosticChannel
Handles consuming and outputting diagnostic events.
Definition
IDiagnosticChannel.cs:10
IKVM.Tools.Core.Diagnostics
Definition
AsyncDiagnosticChannelWriter.cs:8
System.Text
Definition
EncodingExtensions.cs:5
System
Definition
HexConverter.cs:9
src
IKVM.Tools.Core
Diagnostics
FileDiagnosticChannelFactory.cs
Generated by
1.12.0