IKVM11
11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
DiagnosticChannelProvider.cs
Go to the documentation of this file.
1
using
System
;
2
using
System.Collections.Concurrent;
3
using
System.Collections.Generic;
4
using
System.Linq;
5
6
namespace
IKVM.Tools.Core.Diagnostics
7
{
8
12
class
DiagnosticChannelProvider
: IDisposable
13
{
14
15
readonly IEnumerable<IDiagnosticChannelFactory> _factories;
16
readonly ConcurrentDictionary<string, IDiagnosticChannel?> _cache =
new
();
17
23
public
DiagnosticChannelProvider
(IEnumerable<IDiagnosticChannelFactory> factories)
24
{
25
_factories = factories ??
throw
new
ArgumentNullException(nameof(factories));
26
}
27
33
public
IDiagnosticChannel
?
GetOrCreateChannel
(
string
spec)
34
{
35
return
_cache.GetOrAdd(spec, _ => _factories.Select(i => i.CreateChannel(_)).FirstOrDefault(i => i !=
null
));
36
}
37
39
public
void
Dispose
()
40
{
41
foreach
(var i
in
_cache.Values)
42
if
(i is IDisposable d)
43
d.Dispose();
44
45
_cache.Clear();
46
}
47
48
}
49
50
}
IKVM.Tools.Core.Diagnostics.DiagnosticChannelProvider
Provides the capability to look up diagnostic channels.
Definition
DiagnosticChannelProvider.cs:13
IKVM.Tools.Core.Diagnostics.DiagnosticChannelProvider.DiagnosticChannelProvider
DiagnosticChannelProvider(IEnumerable< IDiagnosticChannelFactory > factories)
Initializes a new instance.
Definition
DiagnosticChannelProvider.cs:23
IKVM.Tools.Core.Diagnostics.DiagnosticChannelProvider.Dispose
void Dispose()
Definition
DiagnosticChannelProvider.cs:39
IKVM.Tools.Core.Diagnostics.DiagnosticChannelProvider.GetOrCreateChannel
IDiagnosticChannel? GetOrCreateChannel(string spec)
Attempts to parse the specification into a diagnostic channel.
Definition
DiagnosticChannelProvider.cs:33
IKVM.Tools.Core.Diagnostics.IDiagnosticChannel
Handles consuming and outputting diagnostic events.
Definition
IDiagnosticChannel.cs:10
IKVM.Tools.Core.Diagnostics
Definition
AsyncDiagnosticChannelWriter.cs:8
System
Definition
HexConverter.cs:9
src
IKVM.Tools.Core
Diagnostics
DiagnosticChannelProvider.cs
Generated by
1.12.0