/** * Constructor. * * @param outputStream Stream where to save cards. * @param saveFormat Format to save file. Only TXT is supported at the moment. * * @warning Only csv, crf and text formats are supported at the moment. If file has any other format * it will be saved as text. */ public CardWriter(MemoryStream outputStream, CardFileFormat.Format saveFormat) { _csvStream = null; _txtStream = null; _crfStream = null; //what format do we have to save? if (saveFormat != CardFileFormat.Format.TXT) { throw new ArgumentException("Only CardFileFormat.Format.TXT is supported with stream output"); } _txtStream = new TxtWriter(outputStream); }
/** * Constructor. * * @param file File name where cards will be saved. If file exists its content will be erased. * If file does not exists it will be created. * @param saveFormat Format to save file. If NONE format will be chosen depending on file extension. * * @warning Only csv, crf and text formats are supported at the moment. If file has any other format * it will be saved as text. */ public CardWriter(string file, CardFileFormat.Format saveFormat) { _csvStream = null; _txtStream = null; _crfStream = null; //what format do we have to save? if (saveFormat == CardFileFormat.Format.NONE) { if (file.EndsWith(Program.extension)) { saveFormat = CardFileFormat.Format.CRF; } else if (file.EndsWith(".csv")) { saveFormat = CardFileFormat.Format.CSV; } else { saveFormat = CardFileFormat.Format.TXT; } } if (saveFormat == CardFileFormat.Format.CRF) { _crfStream = new CrfWriter(file); } else if (saveFormat == CardFileFormat.Format.CSV) { _csvStream = new CsvWriter(file); } else //use txt as default { _txtStream = new TxtWriter(file); } }