Example #1
0
        private static void Main()
        {
            var dtog = new DataTransferObjectGenerator();
            var databaseTableDefinition = new DatabaseTableDefinition
            {
                Name    = "Foobar",
                Columns = new[]
                {
                    new DatabaseColumnDefinition
                    {
                        SqlDataType = SqlDataType.NVarchar,
                        IsIdentity  = false,
                        IsNullable  = true,
                        Name        = "Name"
                    },
                    new DatabaseColumnDefinition
                    {
                        SqlDataType = SqlDataType.Decimal,
                        IsIdentity  = false,
                        IsNullable  = true,
                        Name        = "HeightInInches"
                    }
                }
            };
            var codeGenerationConfiguration = new CodeGenerationConfiguration
            {
                CoreNamespace = "Birchy.Core"
            };
            var generate = dtog.GenerateCode(codeGenerationConfiguration, databaseTableDefinition);

            System.Console.WriteLine(generate);
        }
Example #2
0
        /// <summary>
        /// </summary>
        private async void GenerateCode()
        {
            var outputPath = txtOutputDirectory.Text;
            var progress   = new Progress <ProgressResult>(ReportProgress);
            var schema     = await ProcessInputFile();

            var tableCount = schema.Tables.Count;

            progressBar.Maximum = 3 + (3 * tableCount) + (2 * tableCount);

            schema.Tables.ForEach(x => x.Initialize(schema.Database));

            var database = schema.Database;

            if (database.ProviderFolder.IsEmpty())
            {
                database.ProviderFolder = Database.DefaultProviderFolder;
            }

            var generatorContent        = new ContractClassGenerator(schema);
            var generatorDatabaseHelper = new DatabaseHelperGenerator(schema);
            var generatorDTO            = new DataTransferObjectGenerator(schema);
            var generatorMetaData       = new MetaDataGenerator(schema);
            var generatorProvider       = new ProviderClassGenerator(schema);
            var generatorSelection      = new SelectionBuilderGenerator(schema);
            var generatorUriType        = new UriTypeGenerator(schema);

            var contentResult = await generatorContent.Generate(outputPath, progress);

            var databaseResult = await generatorDatabaseHelper.Generate(outputPath, progress);

            var dtoResult = await generatorDTO.Generate(outputPath, progress);

            var metaResult = await generatorMetaData.Generate(outputPath, progress);

            var providerResult = await generatorProvider.Generate(outputPath, progress);

            var selectionResult = await generatorSelection.Generate(outputPath, progress);

            var uriResult = await generatorUriType.Generate(outputPath, progress);

            FileUtils.SaveFile(contentResult.Path, contentResult.Content);
            FileUtils.SaveFile(databaseResult.Path, databaseResult.Content);
            FileUtils.SaveFile(dtoResult.Path, dtoResult.Content);
            FileUtils.SaveFile(metaResult.Path, metaResult.Content);
            FileUtils.SaveFile(providerResult.Path, providerResult.Content);
            FileUtils.SaveFile(selectionResult.Path, selectionResult.Content);
            FileUtils.SaveFile(uriResult.Path, uriResult.Content);

            End();
        }
        /// <summary>
        /// </summary>
        private async void GenerateCode() {
            var outputPath = txtOutputDirectory.Text;
            var progress = new Progress<ProgressResult>(ReportProgress);
            var schema = await ProcessInputFile();
            var tableCount = schema.Tables.Count;

            progressBar.Maximum = 3 + (3 * tableCount) + (2 * tableCount);

            schema.Tables.ForEach(x => x.Initialize(schema.Database));

            var database = schema.Database;
            if (database.ProviderFolder.IsEmpty()) {
                database.ProviderFolder = Database.DefaultProviderFolder;
            }

            var generatorContent = new ContractClassGenerator(schema);
            var generatorDatabaseHelper = new DatabaseHelperGenerator(schema);
            var generatorDTO = new DataTransferObjectGenerator(schema);
            var generatorMetaData = new MetaDataGenerator(schema);
            var generatorProvider = new ProviderClassGenerator(schema);
            var generatorSelection = new SelectionBuilderGenerator(schema);
            var generatorUriType = new UriTypeGenerator(schema);

            var contentResult = await generatorContent.Generate(outputPath, progress);
            var databaseResult = await generatorDatabaseHelper.Generate(outputPath, progress);
            var dtoResult = await generatorDTO.Generate(outputPath, progress);
            var metaResult = await generatorMetaData.Generate(outputPath, progress);
            var providerResult = await generatorProvider.Generate(outputPath, progress);
            var selectionResult = await generatorSelection.Generate(outputPath, progress);
            var uriResult = await generatorUriType.Generate(outputPath, progress);

            FileUtils.SaveFile(contentResult.Path, contentResult.Content);
            FileUtils.SaveFile(databaseResult.Path, databaseResult.Content);
            FileUtils.SaveFile(dtoResult.Path, dtoResult.Content);
            FileUtils.SaveFile(metaResult.Path, metaResult.Content);
            FileUtils.SaveFile(providerResult.Path, providerResult.Content);
            FileUtils.SaveFile(selectionResult.Path, selectionResult.Content);
            FileUtils.SaveFile(uriResult.Path, uriResult.Content);

            End();
        }