コード例 #1
0
ファイル: Solution.cs プロジェクト: sourcewarehouse/janett
        public void Save()
        {
            Discovery dis = new Discovery();
            dis.AddAssembly(Assembly.GetExecutingAssembly());
            Stream stream = dis.GetResource("SolutionTemplate.txt");

            using (StreamReader reader = new StreamReader(stream))
            {
                string solutionContents = reader.ReadToEnd();

                string solutionPath = Path.Combine(Folder, SolutionName + ".sln");
                string projectsSection = "";
                foreach (Project project in Projects)
                {
                    project.RelPath = Path.Combine(project.OutputFolder.Replace(Folder + Path.DirectorySeparatorChar, ""), project.Name + ".csproj");
                    projectsSection += string.Format("Project(\"{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}\") = \"{0}\", \"{1}\", \"{2}\"\r\n" +
                                                     "\tProjectSection(ProjectDependencies) = postProject\r\n" +
                                                     "\tEndProjectSection\r\n" +
                                                     "EndProject\r\n", project.Name, project.RelPath, "{" + project.Guid + "}");
                }

                solutionContents = solutionContents.Replace("#Projects#", projectsSection.TrimEnd('\r', '\n'));
                string configurationTemplate = "\t\t{0}.Debug.ActiveCfg = Debug|.NET\r\n" +
                                               "\t\t{0}.Debug.Build.0 = Debug|.NET\r\n" +
                                               "\t\t{0}.Release.ActiveCfg = Release|.NET\r\n" +
                                               "\t\t{0}.Release.Build.0 = Release|.NET\r\n";
                string configuration = "";
                foreach (Project project in Projects)
                {
                    configuration += string.Format(configurationTemplate, "{" + project.Guid + "}");
                }
                solutionContents = solutionContents.Replace("#Configuration#", "\r\n" + configuration + "\t");
                FileSystemUtil.WriteFile(solutionPath, solutionContents);
            }
        }
コード例 #2
0
ファイル: Solution.cs プロジェクト: wangchengqun/janett
        public void Save()
        {
            Discovery dis = new Discovery();

            dis.AddAssembly(Assembly.GetExecutingAssembly());
            Stream stream = dis.GetResource("SolutionTemplate.txt");

            using (StreamReader reader = new StreamReader(stream))
            {
                string solutionContents = reader.ReadToEnd();

                string solutionPath    = Path.Combine(Folder, SolutionName + ".sln");
                string projectsSection = "";
                foreach (Project project in Projects)
                {
                    project.RelPath  = Path.Combine(project.OutputFolder.Replace(Folder + Path.DirectorySeparatorChar, ""), project.Name + ".csproj");
                    projectsSection += string.Format("Project(\"{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}\") = \"{0}\", \"{1}\", \"{2}\"\r\n" +
                                                     "\tProjectSection(ProjectDependencies) = postProject\r\n" +
                                                     "\tEndProjectSection\r\n" +
                                                     "EndProject\r\n", project.Name, project.RelPath, "{" + project.Guid + "}");
                }

                solutionContents = solutionContents.Replace("#Projects#", projectsSection.TrimEnd('\r', '\n'));
                string configurationTemplate = "\t\t{0}.Debug.ActiveCfg = Debug|.NET\r\n" +
                                               "\t\t{0}.Debug.Build.0 = Debug|.NET\r\n" +
                                               "\t\t{0}.Release.ActiveCfg = Release|.NET\r\n" +
                                               "\t\t{0}.Release.Build.0 = Release|.NET\r\n";
                string configuration = "";
                foreach (Project project in Projects)
                {
                    configuration += string.Format(configurationTemplate, "{" + project.Guid + "}");
                }
                solutionContents = solutionContents.Replace("#Configuration#", "\r\n" + configuration + "\t");
                FileSystemUtil.WriteFile(solutionPath, solutionContents);
            }
        }
コード例 #3
0
        public override void Execute()
        {
            DateTime start = DateTime.Now;

            if (ExecutableDirectory == null)
            {
                ExecutableDirectory = Path.GetFullPath(".");
            }

            diagnosticsFile = Path.Combine(ExecutableDirectory, "Exception.txt");
            if (DiagnosticsMode && File.Exists(diagnosticsFile))
            {
                Diagnostics.BreakOn(FileSystemUtil.ReadFile(diagnosticsFile));
            }

            InputFolder = Path.GetFullPath(InputFolder);
            if (!Directory.Exists(InputFolder))
            {
                throw new ApplicationException("Input folder does not exists.");
            }

            LoadOptions();
            SetDefaultValues();
            ValidateParameters();

            if (Projects.Count == 0)
            {
                Project project = GetDefaultProject();
                Projects.Add(project);
            }

            Mappings = Path.GetFullPath(Mappings);
            SetOutputFolder();

            Discovery.AddAssembly(Assembly.GetExecutingAssembly());
            Discovery.AddAssembly(GetType().Assembly);

            string folderName       = Solution + "-" + Mode;
            string translatedFolder = "Translated" + Path.DirectorySeparatorChar + folderName;

            translatedFolder = Path.Combine(ExecutableDirectory, translatedFolder);
            string patchFile = Path.GetFullPath(Path.Combine(InputFolder, Mode + ".patch"));

            if (PreserveChanges)
            {
                CreateDiff(patchFile, translatedFolder);
            }

            Translate();

            if (CreateProjects)
            {
                CreateSolutionAndProject();
            }

            if (PreserveChanges)
            {
                progress.Increment("CopyTranslated");
                CopyDirectory(OutputFolder, translatedFolder);
            }

            if (File.Exists(patchFile))
            {
                progress.Increment("Patch");
                CallProcess("patch.exe", options.GetKey("Preservation", "PatchParameters") + " -d " + OutputFolder + " -i " + patchFile);
            }

            if (File.Exists(diagnosticsFile))
            {
                File.Delete(diagnosticsFile);
            }
            TimeSpan timespan = DateTime.Now - start;

            Console.WriteLine("\n\nTranslation took {0} seconds.", (int)timespan.TotalSeconds);
        }