using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Text; using System.Threading; using System.Collections.Concurrent; using System.Threading.Tasks; namespace Tango.CSV { /// /// Represents a destination. /// public class CsvDestination { public StreamWriter StreamWriter; /// /// Performs an implicit conversion from to . /// /// The path. /// /// The result of the conversion. /// public static implicit operator CsvDestination(string path) { return new CsvDestination(path); } /// /// Initializes a new instance of the class. /// /// The stream writer. private CsvDestination(StreamWriter streamWriter) { this.StreamWriter = streamWriter; } /// /// Initializes a new instance of the class. /// /// The stream. private CsvDestination(Stream stream) { this.StreamWriter = new StreamWriter(stream); } /// /// Initializes a new instance of the class. /// /// The full name. public CsvDestination(string fullName) { FixCsvFileName(ref fullName); this.StreamWriter = new StreamWriter(fullName); } /// /// Fixes the name of the CSV file. /// /// The full name. private static void FixCsvFileName(ref string fullName) { fullName = Path.GetFullPath(fullName); var path = Path.GetDirectoryName(fullName); if (path != null && !Directory.Exists(path)) Directory.CreateDirectory(path); if (!String.Equals(Path.GetExtension(fullName), ".csv")) fullName += ".csv"; } } }