Пример #1
0
    public void Create(IGeneratorConfiguration configuration)
    {
        _logger.LogInformation("Generation started: {Started}", DateTime.Now.ToShortTimeString());

        var result = Context.ValidateConfiguration(configuration);

        if (!result.IsValid)
        {
            _logger.LogInformation("Generation failed: {Failed}", DateTime.Now.ToShortTimeString());
            return;
        }

        var output = _codeGenerator.Create(Context);

        try
        {
            var outputPath   = Context.Settings?.OutputPath ?? Directory.GetCurrentDirectory();
            var supportRegen = Context.Settings?.SupportRegen ?? true;

            _outputStrategy.Create(output, outputPath, supportRegen);
            _logger.LogInformation("Generation complete: {Complete}", DateTime.Now.ToShortTimeString());
        }
        catch (InvalidOperationException ex)
        {
            _logger.LogError(ex, "Generation skipped for Module '{Module}' as there was no defined output strategy", Context.Module?.Name + string.Empty);
        }
    }