/// <summary>
        /// Opens the <see cref="CSVReaderWriter"/> for reading or writing the data
        /// </summary>
        /// <param name="csvPath">Path or location of the CSV</param>
        /// <param name="mode">Whether to open for reading or writing</param>
        public void Open(string csvPath, Mode mode)
        {
            if (mode == Mode.Read)
            {
                if (csvReader == null)
                {
                    throw new ApplicationException("CSV reader is null");
                }

                // In older code, CSVReaderWriter can be opened for read multiple times
                // To maintain backward compatibility, close existing opened
                // reader, so that it can be reopened.
                csvReader.Close();
                csvReader.Open(csvPath);
            }
            else if (mode == Mode.Write)
            {
                if (csvWriter == null)
                {
                    throw new ApplicationException("CSV writer is null");
                }

                // In older code, CSVReaderWriter can be opened for write multiple times
                // To maintain backward compatibility, close existing opened
                // writer, so that it can be reopened.
                csvWriter.Close();
                csvWriter.Open(csvPath);
            }
            else
            {
                throw new Exception("Unknown file mode for " + csvPath);
            }
        }
Beispiel #2
0
 public static IObserver <T> ToObserver <T>(this IDataWriter writer)
 {
     return(System.Reactive.Observer.Create <T>
            (
                onNext: data => writer.Write(data),
                onError: _ => writer.Close(),
                onCompleted: () => writer.Close()
            ));
 }
Beispiel #3
0
 public void Close()
 {
     _subject.OnCompleted();
     _writer.Close();
 }