namespace MeetTheTeacher.Export; /// /// Base class for exporters which write data to a file /// public abstract class FileExporterBase { /// /// File extension of the exported file including the dot /// protected abstract string FileExtension { get; } /// /// Exports the given content to a file with the given name. /// If the file already exists, it will be overwritten. /// /// Name of the file to export without the extension /// Content to write into the file protected void Export(string fileName, string content) { string filePath = GetFilePath(fileName); File.WriteAllText(filePath, content); } /// /// Joins several lines into one text, separated by line breaks /// /// Lines to merge /// A text containing all lines protected static string LinesToText(IEnumerable lines) => string.Join(Environment.NewLine, lines); private string GetFilePath(string fileName) { return Path.Combine(Directory.GetCurrentDirectory(), $"{fileName}{FileExtension}"); } }