# HG changeset patch
# User cin
# Date 2018-06-15 16:34:02
# Node ID 90cef6117ced6f5da9b1760a913f3436f015fdd5
# Parent 78da52bb28f02c12c0aaf8bd9ad075af05b3d59a
Added IObservable to TraceRegistry
diff --git a/Implab.Playground/Implab.Playground.csproj b/Implab.Playground/Implab.Playground.csproj
--- a/Implab.Playground/Implab.Playground.csproj
+++ b/Implab.Playground/Implab.Playground.csproj
@@ -19,7 +19,9 @@
-
+
+
+
diff --git a/Implab.Playground/Program.cs b/Implab.Playground/Program.cs
--- a/Implab.Playground/Program.cs
+++ b/Implab.Playground/Program.cs
@@ -12,6 +12,7 @@ using Unity.Injection;
using Unity.Registration;
namespace Implab.Playground {
+ using System.Reactive.Linq;
using static Trace;
class Foo {
@@ -27,14 +28,10 @@ namespace Implab.Playground {
Trace.Log("First!");
Log("+1!");
- using(TraceRegistry.Global.Subscribe(x => {
- var ch = x as TraceSourceChannel;
- if (ch == null)
- return;
-
+ using(TraceRegistry.Global.OfType().Subscribe(ch => {
Console.WriteLine($"{ch.Id}: {ch.Source.Name}");
- }, true)) {
+ })) {
Trace.Log("Hi!");
Log("Respect!");
}
diff --git a/Implab.ServiceHost/Implab.ServiceHost.csproj b/Implab.ServiceHost/Implab.ServiceHost.csproj
--- a/Implab.ServiceHost/Implab.ServiceHost.csproj
+++ b/Implab.ServiceHost/Implab.ServiceHost.csproj
@@ -17,7 +17,7 @@
-
+
diff --git a/Implab.Test/DiagnosticsTest.cs b/Implab.Test/DiagnosticsTest.cs
--- a/Implab.Test/DiagnosticsTest.cs
+++ b/Implab.Test/DiagnosticsTest.cs
@@ -23,14 +23,7 @@ namespace Implab.Test {
TraceRegistry.Global.Subscribe(x => {
visited++;
found = x as TraceSourceChannel;
- }, false);
-
- Assert.Equal(0, visited);
-
- TraceRegistry.Global.Subscribe(x => {
- visited++;
- found = x as TraceSourceChannel;
- }, true);
+ });
Assert.Equal(1,visited);
Assert.Equal(channel, found);
diff --git a/Implab.Test/Implab.Test.csproj b/Implab.Test/Implab.Test.csproj
--- a/Implab.Test/Implab.Test.csproj
+++ b/Implab.Test/Implab.Test.csproj
@@ -14,6 +14,7 @@
+
diff --git a/Implab/Diagnostics/TraceRegistry.cs b/Implab/Diagnostics/TraceRegistry.cs
--- a/Implab/Diagnostics/TraceRegistry.cs
+++ b/Implab/Diagnostics/TraceRegistry.cs
@@ -4,11 +4,10 @@ using System.Diagnostics;
using Implab.Parallels;
namespace Implab.Diagnostics {
- public class TraceRegistry {
+ public class TraceRegistry: IObservable {
class Subscription : IDisposable {
readonly WeakReference m_registry;
- readonly Action