Exemplo n.º 1
0
        public void Generate()
        {
            var sourceFiles = _codeGenerator.ExecutePluginsToFiles(_pluginRepository, "/*", "*/", _initialDomCodeGenerator);

            foreach (var sourceFile in sourceFiles)
            {
                _sourceWriter.Add(sourceFile.Key + ".cs", sourceFile.Value);
            }
        }
Exemplo n.º 2
0
        public void Generate()
        {
            var sourceFiles = _codeGenerator.ExecutePluginsToFiles(_pluginRepository, "/*", "*/", null);

            if (!string.IsNullOrEmpty(_buildEnvironment.GeneratedSourceFolder))
            {
                foreach (var sourceFile in sourceFiles)
                {
                    _sourceWriter.Add(sourceFile.Key + ".cs", sourceFile.Value.GeneratedCode);
                }
            }
            else
            {
                var targetAssemblies = sourceFiles
                                       .GroupBy(sourceFile => sourceFile.Key.Split('\\').First())
                                       .Select(sourceFileGroup => new
                {
                    Name           = sourceFileGroup.Key,
                    AssemblySource = new AssemblySource
                    {
                        GeneratedCode        = string.Join("\r\n", sourceFileGroup.OrderBy(sourceFile => sourceFile.Key).Select(sourceFile => sourceFile.Value.GeneratedCode)),
                        RegisteredReferences = sourceFileGroup.SelectMany(sourceFile => sourceFile.Value.RegisteredReferences).Distinct().OrderBy(name => name)
                    },
                    AssemblyFile = Paths.GetDomAssemblyFile((DomAssemblies)Enum.Parse(typeof(DomAssemblies), sourceFileGroup.Key)),
                })
                                       .ToList();

                Graph.SortByGivenOrder(targetAssemblies,
                                       new string[] { DomAssemblies.Model.ToString(), DomAssemblies.Orm.ToString(), DomAssemblies.Repositories.ToString() },
                                       targetAssembly => targetAssembly.Name);
                AddReferences(targetAssemblies[1].AssemblySource, new[] { targetAssemblies[0].AssemblyFile });
                AddReferences(targetAssemblies[2].AssemblySource, new[] { targetAssemblies[0].AssemblyFile, targetAssemblies[1].AssemblyFile });

                foreach (var targetAssembly in targetAssemblies)
                {
                    _assemblyGenerator.Generate(targetAssembly.AssemblySource, targetAssembly.AssemblyFile);
                }
            }
        }