Пример #1
0
 public void Open(string fileName, Mode mode)
 {
     if (mode == Mode.Read)
     {
         csvReader = new CSVReader(fileName);
     }
     else if (mode == Mode.Write)
     {
         csvWriter = new CSVWriter(fileName);
     }
     else
     {
         throw new Exception("Unknown file mode for " + fileName);
     }
 }
Пример #2
0
        /// <summary>
        /// Protected Dispose implementation that child implementations can override, allowing the base type to simply implement the IDisposable interface
        /// and use a virtual method call to resolve the right Dispose logic
        /// </summary>
        /// <param name="disposeManaged">Whether to dispose managed objects</param>
        protected virtual void Dispose(bool disposeManaged)
        {
            if (!_disposeCalled)
            {
                if (disposeManaged)
                {
                    _reader?.Dispose();
                    _writer?.Dispose();

                    _writer = null;
                    _reader = null;
                }

                _disposeCalled = true;
            }
        }
Пример #3
0
 /// <summary>
 /// Opens the specified file in the specified mode, multiple calls are required if you wish to read and write to the same file.
 /// Method behaviour is preserved for backcompat purposes.
 /// </summary>
 /// <param name="fileName">The file to open</param>
 /// <param name="mode">The mode to open the file in (e.g. reading or writing)</param>
 public void Open(string fileName, Mode mode)
 {
     // As the "Mode" enum is marked as [Flags], callers could use it in a bitfield fashion. But because this is production code, changing this behaviour to
     // something like if ((mode & Mode.Read) == Mode.Read) { } if ((mode & Mode.Write) == Mode.Write) { } to allow for opening a reader and writer in one call would
     // be a breaking change.
     if (mode == Mode.Read)
     {
         _reader = new CSVReader(Separator, File.OpenRead(fileName));
     }
     else if (mode == Mode.Write)
     {
         _writer = new CSVWriter(Separator, File.OpenWrite(fileName));
     }
     else
     {
         throw new ArgumentException($"Unknown file mode {(int)mode} specified for " + fileName);
     }
 }
Пример #4
0
 public CSVReaderWriter()
 {
     csvReader = new CSVReader();
     csvWriter = new CSVWriter();
 }
Пример #5
0
 public CSVReaderWriter()
 {
     _CSVReader = new CSVReader();
     _CSVWriter = new CSVWriter();
 }