Exemplo n.º 1
0
        internal CSVTableFromText(IDisposing <TextReader> text)
        {
            reader = text.UseAsIDisposable();

            // All subscriptions will get all values.
            // Reading won't begin until a connection is established.
            var lines = Observable.Generate(
                string.Empty,
                line => line != null,
                _ => reader.Value.ReadLine(),
                line => line)
                        .Replay();

            header = lines.FirstAsync().Select(row => new Header(row)).ToFuture();
            rows   = lines.Skip(2).Select(line => new Row(line));

            // Reader will be disposed as soon as all the lines have been read, or on error.
            readerLifetime = lines.LastAsync().Subscribe(
                _ => reader.Dispose(),
                ex => reader.Dispose());

            // The lines won't be read until needed.
            connection = new Lazy <IDisposable>(() => lines.Connect());
        }
Exemplo n.º 2
0
 internal TransactionsFromText(IDisposing <TextReader> textReader) =>
 this.table = new CSVTableFromText(textReader);
Exemplo n.º 3
0
 public static IObservable <Row> From(IDisposing <TextReader> text) => new TransactionsFromText(text);
Exemplo n.º 4
0
#pragma warning disable CA1062 // Validate arguments of public methods
        public static CSVTable Table(IDisposing <TextReader> text) => new CSVTableFromText(text);