/CsvLogTailer.Tests/LogRecordObservableExtensions.cs
https://bitbucket.org/emertechie/csvlogtailer · C# · 25 lines · 24 code · 1 blank · 0 comment · 0 complexity · 6be242a2242ab02c91e9a87994060746 MD5 · raw file
- using System;
- using System.Collections.Concurrent;
- using System.Reactive;
- using System.Reactive.Linq;
-
- namespace CsvLogTailing.Tests
- {
- public static class LogRecordObservableExtensions
- {
- public static IDisposable MaintainObservedEventsCollection(
- this IObservable<LogRecord> tailedEvents,
- BlockingCollection<Notification<LogRecord>> observedEvents)
- {
- return tailedEvents
- .Materialize()
- .Subscribe(
- observedEvents.Add,
- err =>
- {
- observedEvents.CompleteAdding();
- throw err;
- });
- }
- }
- }