Azavea.Open.DAO.CSV.CsvDaLayer.GetWriter C# (CSharp) Method

GetWriter() protected method

Gets a valid TextWriter that can be used to output CSV data. If we were configured with a TextWriter, it may be that one. If we are accessing a file we will open a new writer. You should not close it yourself, instead you should call DoneWithWriter when you are done with it.
protected GetWriter ( ClassMapping mapping, bool append ) : WriterInfo
mapping ClassMapping The mapping for the object we intend to write.
append bool Whether to append to, or overwrite, the file if it exists. /// If it does not exist, this parameter doesn't matter and a new /// file is created.
return WriterInfo
        protected internal WriterInfo GetWriter(ClassMapping mapping, bool append)
        {
            try
            {
                switch (_connDesc.Type)
                {
                    case CsvConnectionType.Directory:
                    case CsvConnectionType.FileName:
                        return new WriterInfo(GetFileName(mapping), append, UseNamedColumns(mapping));
                    case CsvConnectionType.Reader:
                        throw new LoggingException("Connection for class " +
                                                   mapping + " was configured as write-only: " + _connDesc.Type);
                    case CsvConnectionType.Writer:
                        // We have a writer specifically set.
                        return new WriterInfo(_connDesc.Writer,
                                              (!_connDesc.HasBeenWrittenTo) && UseNamedColumns(mapping));
                    default:
                        throw new LoggingException("Unable to get writer for class " +
                                                   mapping + " for unsupported connection type: " + _connDesc.Type);
                }
            }
            catch (Exception e)
            {
                throw new LoggingException("Unable to get writer for connection " +
                                           _connDesc + ", mapping " + mapping, e);
            }
        }