Archived
Added report generation
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
using ReportGenerator.Generator.Abstract;
|
||||
using ReportGenerator.Generator.Interface;
|
||||
using ReportGenerator.Generator.Interface;
|
||||
using ReportGenerator.Generator.Model;
|
||||
using ReportGenerator.Models;
|
||||
|
||||
namespace ReportGenerator;
|
||||
|
||||
public class ReportGenerator : FileSerializableBase
|
||||
public class ReportGenerator : IDisposable
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string FileExtension => Document.FileExtension;
|
||||
|
||||
private IDocumentGenerator Document { get; }
|
||||
|
||||
private ICollection<ImageStats> Images { get; }
|
||||
@@ -19,30 +15,34 @@ public class ReportGenerator : FileSerializableBase
|
||||
IEnumerable<ImageStats> data
|
||||
)
|
||||
{
|
||||
Document = document;
|
||||
Images = data.ToArray();
|
||||
|
||||
Document = document;
|
||||
document.Open();
|
||||
}
|
||||
|
||||
public ReportGenerator(
|
||||
string title,
|
||||
IDocumentGenerator document,
|
||||
IEnumerable<ImageStats> data
|
||||
) : this(document, data)
|
||||
{
|
||||
WithTitle(title);
|
||||
}
|
||||
) : this(document, data) => AddTitle(title);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString() => Document.ToString();
|
||||
#region Writing
|
||||
|
||||
#region Report content generation
|
||||
|
||||
public ReportGenerator WithTitle(string text)
|
||||
public ReportGenerator AddTitle(string text)
|
||||
{
|
||||
Document.AppendHeading(1, text);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReportGenerator AddProcessorStats(string title)
|
||||
{
|
||||
Document.AppendHeading(2, title);
|
||||
|
||||
// todo show best/worst images per processor
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReportGenerator AddImageStatsFull(string title)
|
||||
{
|
||||
Document.AppendHeading(2, title);
|
||||
@@ -86,7 +86,7 @@ public class ReportGenerator : FileSerializableBase
|
||||
}
|
||||
})
|
||||
.AppendParagraph(
|
||||
$"*Comparison data generated based on {stat.Reference.Count} tagged words.*"
|
||||
$"Comparison data generated based on {stat.Reference.Count} tagged words."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -167,4 +167,23 @@ public class ReportGenerator : FileSerializableBase
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
Document.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user