Exemplo n.º 1
0
        private static void BuildGatewayProject(string solutionDirectory, string projectDirectory, string solutionFolder, string gatewayProjectName, IFileSystem fileSystem)
        {
            var gatewayProjectClassPath = ClassPathHelper.GatewayProjectClassPath(projectDirectory, gatewayProjectName);

            GatewayCsProjBuilder.CreateGatewayCsProj(projectDirectory, gatewayProjectName);
            Utilities.ExecuteProcess("dotnet", $@"sln add ""{gatewayProjectClassPath.FullClassPath}"" --solution-folder {solutionFolder}", solutionDirectory);

            GatewayAppSettingsBuilder.CreateBaseAppSettings(projectDirectory, gatewayProjectName);
            GatewayLaunchSettingsBuilder.CreateLaunchSettings(projectDirectory, gatewayProjectName, fileSystem);
            ProgramBuilder.CreateGatewayProgram(projectDirectory, gatewayProjectName, fileSystem);
            StartupBuilder.CreateGatewayStartup(projectDirectory, "Startup", gatewayProjectName);
        }
Exemplo n.º 2
0
        public static void CreateGatewayCsProj(string solutionDirectory, string gatewayProjectName)
        {
            try
            {
                var classPath = ClassPathHelper.GatewayProjectClassPath(solutionDirectory, gatewayProjectName);

                if (!Directory.Exists(classPath.ClassDirectory))
                {
                    Directory.CreateDirectory(classPath.ClassDirectory);
                }

                if (File.Exists(classPath.FullClassPath))
                {
                    throw new FileAlreadyExistsException(classPath.FullClassPath);
                }

                using (FileStream fs = File.Create(classPath.FullClassPath))
                {
                    var data = "";
                    data = GetGatewayCsProjFileText();
                    fs.Write(Encoding.UTF8.GetBytes(data));
                }

                GlobalSingleton.AddCreatedFile(classPath.FullClassPath.Replace($"{solutionDirectory}{Path.DirectorySeparatorChar}", ""));
            }
            catch (FileAlreadyExistsException e)
            {
                WriteError(e.Message);
                throw;
            }
            catch (Exception e)
            {
                WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}");
                throw;
            }
        }