Ejemplo n.º 1
0
        private static void RunProgram(ProgramArgs args)
        {
            var deserializer = new DeserializerBuilder().Build();

            using var dbs = new StreamReader(Path.Combine(args.InputDirectory, "info.yml"));
            var loadedDatabase = deserializer.Deserialize <LoadedDatabase>(dbs);

            Directory.CreateDirectory(args.OutputDirectory);

            ICodeGenerator generator = args.Language switch
            {
                CodeLanguage.CPP => new CppGenerator(),
                _ => throw new ArgumentOutOfRangeException()
            };

            foreach (var loadedDatabaseClass in loadedDatabase.Classes)
            {
                //if (loadedDatabaseClass.Name != "ecar") continue;

                var contents = generator.GenerateClassLayout(loadedDatabaseClass);
                //Debug.WriteLine("generated {0}", new object[] { loadedDatabaseClass.Name });
                //Debug.WriteLine(contents);
                File.WriteAllText(
                    Path.Combine(args.OutputDirectory, loadedDatabaseClass.Name + generator.GetExtension()),
                    contents);
            }
        }
    }