This repository has been archived by the owner on Sep 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Typiqally/feat/multiple_exporters
Add support for multiple exporters
- Loading branch information
Showing
15 changed files
with
196 additions
and
123 deletions.
There are no files selected for viewing
8 changes: 0 additions & 8 deletions
8
Epsilon.Abstractions/Export/ICanvasModuleCollectionExporter.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Epsilon.Abstractions.Export; | ||
|
||
public interface IExporter<in T> | ||
{ | ||
public IEnumerable<string> Formats { get; } | ||
|
||
void Export(T data, string format); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Epsilon.Abstractions.Export; | ||
|
||
public interface IModuleExporterCollection | ||
{ | ||
public IDictionary<string, ICanvasModuleExporter> DetermineExporters(IEnumerable<string> formats); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Epsilon.Export.Exceptions; | ||
|
||
[Serializable] | ||
public class NoExportersFoundException : Exception | ||
{ | ||
public NoExportersFoundException() | ||
{ | ||
} | ||
|
||
public NoExportersFoundException(IEnumerable<string> formats) : base($"No exporters could be found with the given formats {string.Join(",", formats)}") | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Epsilon.Export; | ||
|
||
public class ExportOptions | ||
{ | ||
public string OutputName { get; set; } = "Epsilon-Export-{DateTime}"; | ||
|
||
public List<string> Formats { get; } = new(); | ||
|
||
public string FormattedOutputName => OutputName | ||
.Replace("{DateTime}", DateTime.Now.ToString("ddMMyyyyHHmmss")); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Epsilon.Abstractions.Export; | ||
using Epsilon.Canvas.Abstractions.Data; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Epsilon.Export.Exporters; | ||
|
||
public class ConsoleModuleExporter : ICanvasModuleExporter | ||
{ | ||
private readonly ILogger<ConsoleModuleExporter> _logger; | ||
|
||
public ConsoleModuleExporter(ILogger<ConsoleModuleExporter> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public IEnumerable<string> Formats { get; } = new[] { "console", "logs" }; | ||
|
||
public void Export(IEnumerable<Module> data, string format) | ||
{ | ||
LogModule(data); | ||
} | ||
|
||
private void LogModule(IEnumerable<Module> modules) | ||
{ | ||
foreach (var module in modules) | ||
{ | ||
_logger.LogInformation("================ {ModuleName} ================", module.Name); | ||
|
||
LogAssignments(module.Assignments); | ||
} | ||
} | ||
|
||
private void LogAssignments(IEnumerable<Assignment> assignments) | ||
{ | ||
foreach (var assignment in assignments) | ||
{ | ||
_logger.LogInformation("{AssignmentName}", assignment.Name); | ||
|
||
LogOutcomeResults(assignment.OutcomeResults); | ||
} | ||
} | ||
|
||
private void LogOutcomeResults(IEnumerable<OutcomeResult> results) | ||
{ | ||
foreach (var outcomeResult in results) | ||
{ | ||
_logger.LogInformation("\t- {OutcomeTitle}", outcomeResult.Outcome?.Title); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.