Exemple #1
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);
        }