Ejemplo n.º 1
0
        public CsvSettings setDefaults(
            bool?strict            = null,
            char?delimiter         = null,
            char?escapeChar        = null,
            char[] charsNeedEscape = null
            )
        {
            if (strict.HasValue)
            {
                this.strict = strict.Value;
            }
            if (delimiter.HasValue)
            {
                this.delimiter = delimiter.Value;
            }
            if (escapeChar.HasValue)
            {
                this.escapeChar = escapeChar.Value;
            }

            if (charsNeedEscape != null)
            {
                this.charsNeedEscape = CsvUtil.createCharsNeedEscape(this.delimiter, this.escapeChar, charsNeedEscape);
            }
            else if (delimiter.HasValue || escapeChar.HasValue)
            {
                this.charsNeedEscape = CsvUtil.createCharsNeedEscape(this.delimiter, this.escapeChar, this.charsNeedEscape);
            }

            return(this);
        }
Ejemplo n.º 2
0
 public CsvSettings(bool strict            = true,
                    char?delimiter         = null,
                    char?escapeChar        = null,
                    char[] charsNeedEscape = null)
 {
     this.strict          = strict;
     this.delimiter       = delimiter ?? CsvUtil.DEFAULT_DELIMITER;
     this.escapeChar      = escapeChar ?? CsvUtil.DEFAULT_ESCAPE_CHAR;
     this.charsNeedEscape = CsvUtil.createCharsNeedEscape(this.delimiter, this.escapeChar, charsNeedEscape);
 }
Ejemplo n.º 3
0
 public CsvWriter(
     TextWriter writer,
     char?delimiter  = null,
     char?escapeChar = null
     )
 {
     this.writer     = writer;
     this.delimiter  = delimiter ?? Settings.DEFAULT_CSV_DELIMITER;
     this.escapeChar = escapeChar ?? Settings.DEFAULT_CSV_ESCAPE_CHAR;
     charsNeedEscape = CsvUtil.createCharsNeedEscape(this.delimiter, this.escapeChar);
 }
Ejemplo n.º 4
0
 public CsvWriter(
     Stream stream,
     Encoding defaultEncoding = null,
     char?delimiter           = null,
     char?escapeChar          = null
     )
 {
     defaultEncoding = defaultEncoding ?? Settings.DEFAULT_ENCODING;
     writer          = new StreamWriter(stream, defaultEncoding);
     this.delimiter  = delimiter ?? Settings.DEFAULT_CSV_DELIMITER;
     this.escapeChar = escapeChar ?? Settings.DEFAULT_CSV_ESCAPE_CHAR;
     charsNeedEscape = CsvUtil.createCharsNeedEscape(this.delimiter, this.escapeChar);
 }