Beispiel #1
0
        public override void Render(CompilationUnitSource source)
        {
            source.AddLine($"public enum {Name}");
            source.StartBlock();

            foreach (string literal in Literals)
            {
                source.AddLine($"{literal},");
            }
            source.EndBlock();
        }
        public override void Render(CompilationUnitSource source)
        {
            if (Namespace != null)
            {
                source.AddLine($"namespace {Namespace}");
                source.StartBlock();
            }

            foreach (CompilationUnitFragment fragment in Fragments)
            {
                fragment.Render(source);
            }

            if (Namespace != null)
            {
                source.EndBlock();
            }
        }
Beispiel #3
0
        public override void Render(CompilationUnitSource source)
        {
            string extends = "";

            if (BaseClass != null)
            {
                extends = $" : {BaseClass}";
            }

            source.AddLine($"public class {Name}{extends}");
            source.StartBlock();

            foreach (CompilationUnitField field in Fields)
            {
                field.Render(source);
            }
            source.EndBlock();
        }
Beispiel #4
0
        public void OutputCode(List <CompilationUnitFragment> fragments, LdtkGeneratorContext ctx)
        {
            Directory.CreateDirectory(OutputDir);

            foreach (CompilationUnitFragment fragment in fragments)
            {
                CompilationUnit cuFile = new CompilationUnit();
                cuFile.Namespace = ctx.CodeSettings.Namespace;
                cuFile.Name      = fragment.Name;
                cuFile.Fragments.Add(fragment);

                CompilationUnitSource source = new CompilationUnitSource(ctx.CodeSettings);
                cuFile.Render(source);

                string filePath = OutputDir + "/" + fragment.Name + ".cs";
                File.WriteAllText(filePath, source.GetSourceCode());
            }
        }