61 lines
1.5 KiB
C#
61 lines
1.5 KiB
C#
using ReportGeneration.Interface;
|
|
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using Microsoft.VisualBasic.CompilerServices;
|
|
|
|
namespace ReportGeneration.Abstract;
|
|
|
|
public abstract class DocumentGeneratorBase : StreamWriterBase, IDocumentGenerator
|
|
{
|
|
/// <inheritdoc />
|
|
protected DocumentGeneratorBase() { }
|
|
|
|
/// <inheritdoc />
|
|
protected DocumentGeneratorBase(Stream stream) : base(stream) { }
|
|
|
|
/// <inheritdoc />
|
|
protected DocumentGeneratorBase(string filePath) : base(File.Open(filePath, FileMode.Create,
|
|
FileAccess.Write))
|
|
{ }
|
|
|
|
/// <inheritdoc />
|
|
protected DocumentGeneratorBase(Stream stream, Encoding encoding) : base(stream, encoding) { }
|
|
|
|
#region Writing
|
|
|
|
/// <inheritdoc />
|
|
public virtual IDocumentGenerator Append(string? text = default)
|
|
{
|
|
Write(text);
|
|
return this;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public virtual IDocumentGenerator AppendLine(string? text = default)
|
|
{
|
|
WriteLine(text);
|
|
return this;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public abstract IDocumentGenerator AppendHeading(int level, string text);
|
|
|
|
/// <inheritdoc />
|
|
public abstract IDocumentGenerator AppendParagraph(string? text = default);
|
|
|
|
/// <inheritdoc />
|
|
public IDocumentGenerator AppendTable(int columns, Action<ITableGenerator> table)
|
|
{
|
|
Write(() => MakeTable(columns, new MemoryStream()), table);
|
|
return this;
|
|
}
|
|
|
|
protected abstract ITableGenerator MakeTable(int columns, Stream stream);
|
|
|
|
#endregion
|
|
|
|
/// <inheritdoc />
|
|
public abstract string FormatImage(string path, IBounds? bounds = default);
|
|
}
|