Esempio n. 1
0
        /// <summary>
        /// Generates code files using the file generators contained by the service.
        /// </summary>
        /// <returns>Dictionary of output results.</returns>
        public Dictionary <GeneratedFileType, IEnumerable <GeneratedFile> > GenerateFiles()
        {
            try
            {
                var specifications = _specificationRepository.GetAll();

                var result = new Dictionary <GeneratedFileType, IEnumerable <GeneratedFile> >();

                foreach (var generator in _fileGenerators)
                {
                    var files = new List <GeneratedFile>();

                    foreach (var spec in specifications)
                    {
                        try
                        {
                            files.Add(generator.GenerateFile(spec));
                        }
                        catch (Exception ex)
                        {
                            _logger.LogError(ex, "Exception during file generation for object {table}.", new { table = (spec.SchemaName + "." + spec.TableName) });
                        }
                    }

                    result.Add(generator.OutputFileType, files);
                }

                return(result);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Exception occured in ModelTemplateService.GenerateTemplates().");
                throw;
            }
        }