コード例 #1
0
        public void TestComplete()
        {
            // Arrange
            var sb = new SourceBuilder();

            // Act
            sb.AL("namespace foo");
            sb.B(sb =>
            {
                sb.AL("public class Bar");
                sb.B(sb =>
                {
                    sb.A("System.Console.WriteLine(", indent: true);
                    sb.A("\"Hello World!\"");
                    sb.A(");");
                    sb.NL();
                    sb.I(sb =>
                    {
                        sb.AL("// Indented comment");
                    });
                });
            });
            var value = sb.ToString();

            // Assert
            Assert.Equal(@"namespace foo
{
    public class Bar
    {
        System.Console.WriteLine(""Hello World!"");
            // Indented comment
    }
}
", value);
        }
コード例 #2
0
        public static string Write(Ast ast)
        {
            var sb = new SourceBuilder();

            sb.AL("#nullable enable");
            sb.NL();
            sb.AL("using System.Linq;");
            sb.NL();
            sb.PublicStaticClass("Allvis.Kaylee.Generated.SqlKata", "Queries", sb =>
            {
                foreach (var schema in ast.Schemata)
                {
                    sb.Write(schema);
                }
            });
            return(sb.ToString());
        }
コード例 #3
0
        private static string Write(this IEnumerable <Schema> schemata)
        {
            var sb = new SourceBuilder();

            sb.AL("#nullable enable");
            sb.NL();
            sb.PublicStaticClass("Allvis.Kaylee.Generated.SqlKata", "Entities", sb =>
            {
                foreach (var schema in schemata)
                {
                    sb.PublicStaticClass(schema.Name, sb =>
                    {
                        foreach (var entity in schema.Entities)
                        {
                            sb.Write(entity);
                        }
                    });
                }
            });
            return(sb.ToString());
        }