Generate() public static méthode

public static Generate ( ICodeGeneratorDataProvider provider, string directory, ICodeGenerator codeGenerators ) : Entitas.CodeGenerator.CodeGenFile[]
provider ICodeGeneratorDataProvider
directory string
codeGenerators ICodeGenerator
Résultat Entitas.CodeGenerator.CodeGenFile[]
        public static void Generate()
        {
            checkCanGenerate();

            Debug.Log("Generating...");

            var config = new CodeGeneratorConfig(EntitasPreferences.LoadConfig());

            var codeGenerator = new Entitas.CodeGenerator.CodeGenerator(
                getEnabled <ICodeGeneratorDataProvider>(config.dataProviders),
                getEnabled <ICodeGenerator>(config.codeGenerators),
                getEnabled <ICodeGenFilePostProcessor>(config.postProcessors)
                );

            var dryFiles = codeGenerator.DryRun();
            var sloc     = dryFiles
                           .Select(file => file.fileContent.ToUnixLineEndings())
                           .Sum(content => content.Split(new [] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Length);

            var files = codeGenerator.Generate();
            var totalGeneratedFiles = files.Select(file => file.fileName).Distinct().Count();
            var loc = files
                      .Select(file => file.fileContent.ToUnixLineEndings())
                      .Sum(content => content.Split(new [] { '\n' }).Length);

            foreach (var file in files)
            {
                Debug.Log(file.generatorName + ": " + file.fileName);
            }

            Debug.Log("Generated " + totalGeneratedFiles + " files (" + sloc + " sloc, " + loc + " loc)");

            AssetDatabase.Refresh();
        }
        public static void Generate()
        {
            checkCanGenerate();

            Debug.Log("Generating...");

            var config = new CodeGeneratorConfig(EntitasPreferences.LoadConfig());

            var codeGenerator = new Entitas.CodeGenerator.CodeGenerator(
                getEnabled <ICodeGeneratorDataProvider>(config.dataProviders),
                getEnabled <ICodeGenerator>(config.codeGenerators),
                getEnabled <ICodeGenFilePostProcessor>(config.postProcessors)
                );

            var progressOffset = 0f;

            codeGenerator.OnProgress += (title, info, progress) => {
                var cancel = EditorUtility.DisplayCancelableProgressBar(title, info, progressOffset + progress / 2);
                if (cancel)
                {
                    codeGenerator.Cancel();
                }
            };

            var dryFiles = codeGenerator.DryRun();

            progressOffset = 0.5f;
            var files = codeGenerator.Generate();

            EditorUtility.ClearProgressBar();

            var totalGeneratedFiles = files.Select(file => file.fileName).Distinct().Count();

            var sloc = dryFiles
                       .Select(file => file.fileContent.ToUnixLineEndings())
                       .Sum(content => content.Split(new [] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Length);

            var loc = files
                      .Select(file => file.fileContent.ToUnixLineEndings())
                      .Sum(content => content.Split(new [] { '\n' }).Length);

            Debug.Log("Generated " + totalGeneratedFiles + " files (" + sloc + " sloc, " + loc + " loc)");

            AssetDatabase.Refresh();
        }
Exemple #3
0
        public static CodeGenFile[] Generate(Assembly assembly, string[] poolNames, string[] blueprintNames, string directory, ICodeGenerator[] codeGenerators)
        {
            var provider = new TypeReflectionProvider(assembly.GetTypes(), poolNames, blueprintNames);

            return(CodeGenerator.Generate(provider, directory, codeGenerators));
        }