Esempio n. 1
0
        public static string GenerateDocumentStorageCode(DocumentMapping[] mappings)
        {
            var writer = new SourceWriter();

            // TODO -- get rid of the magic strings
            var namespaces = new List <string> {
                "System", "Marten", "Marten.Schema", "Marten.Linq", "Marten.Util", "Npgsql", "Remotion.Linq"
            };

            namespaces.AddRange(mappings.Select(x => x.DocumentType.Namespace));

            namespaces.Distinct().OrderBy(x => x).Each(x => writer.WriteLine($"using {x};"));
            writer.BlankLine();

            writer.StartNamespace("Marten.GeneratedCode");

            mappings.Each(x =>
            {
                x.GenerateDocumentStorage(writer);
                writer.BlankLine();
                writer.BlankLine();
            });

            writer.FinishBlock();

            var code = writer.Code();

            return(code);
        }
Esempio n. 2
0
        public static string GenerateDocumentStorageCode(DocumentMapping[] mappings)
        {
            var writer = new SourceWriter();

            // TODO -- get rid of the magic strings
            var namespaces = new List<string> {"System", "Marten", "Marten.Schema", "Marten.Linq", "Marten.Util", "Npgsql", "Remotion.Linq"};
            namespaces.AddRange(mappings.Select(x => x.DocumentType.Namespace));

            namespaces.Distinct().OrderBy(x => x).Each(x => writer.WriteLine($"using {x};"));
            writer.BlankLine();

            writer.StartNamespace("Marten.GeneratedCode");

            mappings.Each(x =>
            {
                x.GenerateDocumentStorage(writer);
                writer.BlankLine();
                writer.BlankLine();
            });

            writer.FinishBlock();

            var code = writer.Code();
            return code;
        }
Esempio n. 3
0
        public void tryit()
        {
            var mapping = new DocumentMapping(typeof(User));
            var writer = new SourceWriter();
            writer.StartNamespace("MyApplication");

            mapping.GenerateDocumentStorage(writer);

            writer.FinishBlock();

            Debug.WriteLine(writer.Code());
        }
Esempio n. 4
0
        public void tryit()
        {
            var mapping = new DocumentMapping(typeof(User));
            var writer  = new SourceWriter();

            writer.StartNamespace("MyApplication");

            mapping.GenerateDocumentStorage(writer);

            writer.FinishBlock();

            Debug.WriteLine(writer.Code());
        }
Esempio n. 5
0
        public static string GenerateDocumentStorageCode(IDocumentMapping[] mappings)
        {
            var writer = new SourceWriter();

            // TODO -- get rid of the magic strings
            var namespaces = new List <string>
            {
                "System",
                "Marten",
                "Marten.Schema",
                "Marten.Services",
                "Marten.Linq",
                "Marten.Util",
                "Npgsql",
                "Remotion.Linq",
                typeof(NpgsqlDbType).Namespace,
                typeof(IEnumerable <>).Namespace,
                typeof(DbDataReader).Namespace,
                typeof(CancellationToken).Namespace,
                typeof(Task).Namespace
            };

            namespaces.AddRange(mappings.Select(x => x.DocumentType.Namespace));

            namespaces.Distinct().OrderBy(x => x).Each(x => writer.WriteLine($"using {x};"));
            writer.BlankLine();

            writer.StartNamespace("Marten.GeneratedCode");

            mappings.Each(x =>
            {
                GenerateDocumentStorage(x, writer);
                writer.BlankLine();
                writer.BlankLine();
            });

            writer.FinishBlock();
            return(writer.Code());
        }
Esempio n. 6
0
        public static string GenerateDocumentStorageCode(DocumentMapping[] mappings)
        {
            var writer = new SourceWriter();

            // TODO -- get rid of the magic strings
            var namespaces = new List<string>
            {
                "System",
                "Marten",
                "Marten.Schema",
                "Marten.Services",
                "Marten.Linq",
                "Marten.Util",
                "Npgsql",
                "Remotion.Linq",
                typeof (NpgsqlDbType).Namespace,
                typeof (IEnumerable<>).Namespace,
                typeof(DbDataReader).Namespace,
                typeof(CancellationToken).Namespace,
                typeof(Task).Namespace
            };
            namespaces.AddRange(mappings.Select(x => x.DocumentType.Namespace));

            namespaces.Distinct().OrderBy(x => x).Each(x => writer.WriteLine($"using {x};"));
            writer.BlankLine();

            writer.StartNamespace("Marten.GeneratedCode");

            mappings.Each(x =>
            {
                GenerateDocumentStorage(x, writer);
                writer.BlankLine();
                writer.BlankLine();
            });

            writer.FinishBlock();
            return writer.Code();
        }