Import from internal git
This commit is contained in:
28
Generator/Controllers/AnalyzeController.cs
Normal file
28
Generator/Controllers/AnalyzeController.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Core;
|
||||
using Core.Events;
|
||||
using Core.Interfaces;
|
||||
using Generator.Services;
|
||||
|
||||
namespace Generator.Controllers;
|
||||
|
||||
public class AnalyzeController : IController
|
||||
{
|
||||
private readonly AnalyzeService _analyzeService;
|
||||
public DisplayEmitter Emitter { get; set; }
|
||||
|
||||
public AnalyzeController(DisplayEmitter emitter, AnalyzeService service)
|
||||
{
|
||||
_analyzeService = service;
|
||||
Emitter = emitter;
|
||||
}
|
||||
|
||||
public string GetSpecText(string folder, string spec) => _analyzeService.GetSpecText(folder, spec);
|
||||
|
||||
public bool CanBeGenerated(string folder, string spec)
|
||||
{
|
||||
return _analyzeService.CanBeGenerated(folder, spec);
|
||||
}
|
||||
|
||||
public IEnumerable<Location> ListSpecs() => _analyzeService.ListSpecs();
|
||||
|
||||
}
|
||||
31
Generator/Controllers/ExportController.cs
Normal file
31
Generator/Controllers/ExportController.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Core;
|
||||
using Core.Events;
|
||||
using Core.Interfaces;
|
||||
using Generator.Services;
|
||||
using Generator.views;
|
||||
|
||||
namespace Generator.Controllers;
|
||||
|
||||
public class ExportController : IController
|
||||
{
|
||||
private readonly ExportService _exportService;
|
||||
public DisplayEmitter Emitter { get; set; }
|
||||
|
||||
public ExportController(DisplayEmitter emitter, ExportService service)
|
||||
{
|
||||
_exportService = service;
|
||||
Emitter = emitter;
|
||||
}
|
||||
|
||||
public void PlantUml(ISpecFile file)
|
||||
{
|
||||
try
|
||||
{
|
||||
_exportService.ExportAsPuml(file);
|
||||
} catch (Exception e)
|
||||
{
|
||||
Emitter.Warn(this, $"{e.Message} \n Cause : {e.Source} \n Full stacktrace : \n {e.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
30
Generator/Controllers/GenerationController.cs
Normal file
30
Generator/Controllers/GenerationController.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Core.Events;
|
||||
using Core.Interfaces;
|
||||
using Core.Process;
|
||||
using Generator.Services;
|
||||
|
||||
namespace Generator.Controllers;
|
||||
|
||||
public class GenerationController : IController
|
||||
{
|
||||
private readonly GenerationService _genService;
|
||||
public DisplayEmitter Emitter { get; set; }
|
||||
|
||||
public GenerationController(DisplayEmitter emitter, GenerationService service)
|
||||
{
|
||||
_genService = service;
|
||||
Emitter = emitter;
|
||||
}
|
||||
|
||||
public async Task Launch(GenerationProcess process)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var task in process) await _genService.Launch(task);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Emitter.Warn(this, $"{e.Message} \n Cause : {e.Source} \n Full stacktrace : \n {e.StackTrace}");
|
||||
}
|
||||
}
|
||||
}
|
||||
37
Generator/Controllers/PreGenerationController.cs
Normal file
37
Generator/Controllers/PreGenerationController.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Core;
|
||||
using Core.Events;
|
||||
using Core.Interfaces;
|
||||
using Core.Process;
|
||||
using Core.SpecConfig;
|
||||
using Generator.Services;
|
||||
using Generator.views;
|
||||
|
||||
namespace Generator.Controllers;
|
||||
|
||||
public class PreGenerationController : IController
|
||||
{
|
||||
private readonly PreGenerationService _preGenService;
|
||||
private readonly ConsoleView _view;
|
||||
public DisplayEmitter Emitter { get; set; }
|
||||
|
||||
public PreGenerationController(DisplayEmitter emitter, PreGenerationService preGenService)
|
||||
{
|
||||
_view = new ConsoleView();
|
||||
_preGenService = preGenService;
|
||||
Emitter = emitter;
|
||||
}
|
||||
|
||||
public GenerationProcess ComputeGeneration(string specPath, GenerationType? generationType, PublishType publishType)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _preGenService.ComputeGeneration(specPath, generationType, publishType);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Emitter.Warn(this, e.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
33
Generator/Controllers/PublicationController.cs
Normal file
33
Generator/Controllers/PublicationController.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Core.Events;
|
||||
using Core.Interfaces;
|
||||
using Core.Process;
|
||||
using Generator.Services;
|
||||
using Generator.views;
|
||||
|
||||
namespace Generator.Controllers;
|
||||
|
||||
public class PublicationController : IController
|
||||
{
|
||||
|
||||
private readonly PublicationService _pubService;
|
||||
public DisplayEmitter Emitter { get; set; }
|
||||
|
||||
public PublicationController(DisplayEmitter emitter, PublicationService pubService)
|
||||
{
|
||||
_pubService = pubService;
|
||||
Emitter = emitter;
|
||||
}
|
||||
|
||||
public async Task Publish(GenerationProcess process)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _pubService.Publish(process);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Emitter.Warn(this, $"{e.Message} \n Cause : {e.Source} \n Full stacktrace : \n {e.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user