コード例 #1
0
        public void DetermineEntityFile(string outputPath, string expectedOutputPathPrefix, string expectedOutputPath)
        {
            var splitFilePath = FilePathSplitter.DetermineEntityFile(outputPath);

            Assert.That(splitFilePath.EntityOutputPathPrefix, Is.EqualTo(expectedOutputPathPrefix));
            Assert.That(splitFilePath.EntityOutputPath, Is.EqualTo(expectedOutputPath));
        }
コード例 #2
0
        public void TestThatFileName_HasSuffix()
        {
            string           originalFilePath = @"C:\Picture\apple.jpg";
            FilePathSplitter filePath         = new FilePathSplitter(originalFilePath);
            string           newFilePath      = filePath.GetFileNameWithSuffix("test");

            Assert.AreEqual("apple_test.jpg", newFilePath);
        }
コード例 #3
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            filePath = new FilePathSplitter(openFileDialog.FileName);

            saveFileDialog.Filter           = "jpeg (*.jpg)|*.jpg|png (*.png)|*.png) ";
            saveFileDialog.InitialDirectory = filePath.GetFileDirectory();
            saveFileDialog.FileName         = filePath.GetFileNameWithSuffix((string)editedImageBox.Image.Tag);

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                image.SaveImage((Bitmap)editedImageBox.Image, saveFileDialog.FileName);
            }
        }
コード例 #4
0
        public async Task GenerateEntities(EntityGenerationRequest request)
        {
            var connectionString = string.Format(@"Data Source={0};Initial Catalog={1};User Id={2};Password={3};",
                                                 request.Server, request.Database, request.Username, request.Password);

            var  generator          = CodeFirstGenerator.Load(connectionString, request.EntityDefinitions.ToDictionary(def => def.TableName, def => def.EntityName));
            bool makePartialClasses = false;

            EntityFile entityFile = FilePathSplitter.DetermineEntityFile(request.OutputPath);

            var projectDirectoryPaths = Directory.GetFiles(entityFile.EntityOutputPath, "*.csproj");

            if (projectDirectoryPaths.Length == 1)
            {
                var projectDirectoryPath = projectDirectoryPaths.Single();

                var project = new Project(projectDirectoryPath);

                var serverPath = FilePathSplitter.DetermineServerPath(request.OutputPath);

                foreach (var entityDefinition in request.EntityDefinitions.Where(table => !generator.IsManyToManyMappingTable(table.TableName)))
                {
                    var tryToSave = _SearchForExistingTableName(entityDefinition.TableName, serverPath);

                    if (tryToSave)
                    {
                        var pocoEntity = EntityGeneratorEngine.GeneratePocoEntity(request.Namespace, entityDefinition.TableName, entityDefinition.EntityName, makePartialClasses, generator);
                        _SaveOutput(request.OutputPath, Path.Combine(entityDefinition.EntityName + ".cs"), entityFile.EntityOutputPathPrefix, pocoEntity, project);

                        var mapping = EntityGeneratorEngine.GenerateMapping(request.Namespace + ".Mapping", entityDefinition.TableName, entityDefinition.EntityName, generator);
                        _SaveOutput(request.OutputPath, Path.Combine("Mapping", entityDefinition.EntityName + "Map.cs"), entityFile.EntityOutputPathPrefix, mapping, project);
                    }
                }

                if (project.IsDirty)
                {
                    _SortProjectDirectory(projectDirectoryPath);
                }

                ProjectCollection.GlobalProjectCollection.UnloadProject(project);
            }
        }
コード例 #5
0
        public void DetermineServerPath(string outPath, string expectedServerpath)
        {
            var serverPath = FilePathSplitter.DetermineServerPath(outPath);

            Assert.That(serverPath, Is.EqualTo(expectedServerpath));
        }