moved generators to folders
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using ReportGeneration.Abstract;
|
||||
using ReportGeneration.Interface;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ReportGeneration.Generators;
|
||||
|
||||
public class MarkdownDocumentGenerator : DocumentGeneratorBase
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public MarkdownDocumentGenerator() { }
|
||||
|
||||
/// <inheritdoc />
|
||||
public MarkdownDocumentGenerator(string filePath) : base(filePath) { }
|
||||
|
||||
/// <inheritdoc />
|
||||
public MarkdownDocumentGenerator(Stream stream) : base(stream) { }
|
||||
|
||||
/// <inheritdoc />
|
||||
public MarkdownDocumentGenerator(Stream stream, Encoding encoding) : base(stream, encoding) { }
|
||||
|
||||
#region Writing
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IDocumentGenerator AppendHeading(int level, string text) =>
|
||||
AppendParagraph(new string('#', level) + ' ' + text);
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override ITableGenerator MakeTable(int columns, Stream stream) =>
|
||||
new MarkdownTableGenerator(columns, stream);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IDocumentGenerator AppendParagraph(string? text = default)
|
||||
{
|
||||
AppendLine(text);
|
||||
AppendLine();
|
||||
return this;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string FormatImage(string path, IBounds? bounds = default) =>
|
||||
HtmlTools.FormatImage(path, default, bounds);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using ReportGeneration.Abstract;
|
||||
using ReportGeneration.Interface;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ReportGeneration.Generators;
|
||||
|
||||
internal class MarkdownTableGenerator : TableGeneratorBase
|
||||
{
|
||||
private const string ColumnSeparator = " | ";
|
||||
|
||||
/// <inheritdoc />
|
||||
public MarkdownTableGenerator(int columns)
|
||||
: base(columns) { }
|
||||
|
||||
/// <inheritdoc />
|
||||
public MarkdownTableGenerator(int columns, Stream stream)
|
||||
: base(columns, stream) { }
|
||||
|
||||
/// <inheritdoc />
|
||||
public MarkdownTableGenerator(int columns, Stream stream, Encoding encoding)
|
||||
: base(columns, stream, encoding) { }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ITableGenerator AppendHeader(IEnumerable<string> row) =>
|
||||
this
|
||||
.AppendRow(row)
|
||||
.AppendRow("---");
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ITableGenerator AppendRow(IEnumerable<string> row)
|
||||
{
|
||||
Writer.WriteLine(ColumnSeparator + string.Join(" | ", row) + ColumnSeparator);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user