public string Create()
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            var code = codeGenerator?.Create() ?? string.Empty;

            try
            {
                using var stream = File.Open(path + name, FileMode.Create, FileAccess.Write);
                using var writer = new StreamWriter(stream);
                writer.Write(code);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                throw;
            }

            AssetDatabase.Refresh();

            return(code);
        }
Beispiel #2
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);
        }
    }
        public string Create()
        {
            var code = codeGenerator?.Create() ?? string.Empty;

            code = string.Format(template, name, code);

            return(code);
        }
        public string Create()
        {
            var stringBuilder = new StringBuilder();
            var code          = codeGenerator?.Create() ?? string.Empty;

            stringBuilder.AppendFormat(template, comment);
            stringBuilder.Append(code);
            code = stringBuilder.ToString();

            return(code);
        }
        public string Create()
        {
            var code    = codeGenerator?.Create() ?? string.Empty;
            var builder = new StringBuilder();

            foreach (var attribut in attributs)
            {
                builder.AppendFormat(template, attribut);
            }

            builder.Append(code);

            return(builder.ToString());
        }
Beispiel #6
0
        public string Create()
        {
            var code    = codeGenerator?.Create() ?? string.Empty;
            var builder = new StringBuilder();

            foreach (var name in names)
            {
                builder.AppendFormat(template, name);
            }

            builder.AppendLine();
            builder.AppendLine(code);

            return(builder.ToString());
        }