Beispiel #1
0
        public void RenameProjectFolder(RenameContext context)
        {
            // Since this method is called first, we do a backup here.
            CreateBackup(context.OldProject);

            Directory.Move(context.OldProject.ProjectDirectory, context.NewProject.ProjectDirectory);
        }
Beispiel #2
0
        public bool Rollback(string solutionDirectoryPath, RenameContext context)
        {
            // Remove the new created folder and the modified solution file.
            string newProjectDirectory  = context.NewProject.ProjectDirectory;
            string modifiedSolutionFile = context.OldProject.SolutionPath;

            if (Directory.Exists(newProjectDirectory))
            {
                Directory.Delete(newProjectDirectory, true);
            }

            if (File.Exists(modifiedSolutionFile))
            {
                File.Delete(modifiedSolutionFile);
            }

            // Now rename the backup folders / files to the old names.
            string backupDirectory    = string.Format("{0}{1}", context.OldProject.ProjectDirectory, Constants.ProjectDirectoryBackupExtension);
            string backupSolutionFile = string.Format("{0}{1}", context.OldProject.SolutionPath, Constants.SolutionBackupExtension);

            if (Directory.Exists(backupDirectory))
            {
                Directory.Move(backupDirectory, context.OldProject.ProjectDirectory);
            }

            if (File.Exists(backupSolutionFile))
            {
                File.Move(backupSolutionFile, context.OldProject.SolutionPath);
            }

            return(true);
        }
Beispiel #3
0
        public void Rename(RenameContext renameContext)
        {
            var renameSuccessfull   = true;
            var rollbackSuccessfull = true;

            this.context = renameContext;

            try
            {
                if (Setup(this.context.Solution))
                {
                    renamer = renamerFactory.GetInstance(this.context.IsUnderVersionControl);
                    Rename(this.context.CommitChanges);
                }
                else
                {
                    string message = string.Format(localizationService.GetString(LocalizationResourceNames.RenameErrorNoSupportedProjectFound), context.OldProject.ProjectDirectory);
                    errorDialogService.HandleError(message);
                    renameSuccessfull = false;
                }
            }
            catch (Exception exception)
            {
                renameSuccessfull = false;
                errorDialogService.HandleError(string.Format("Exception:{0}{1}{2}Stacktrace:{3}{4}{5}", Environment.NewLine, exception.Message, Environment.NewLine, Environment.NewLine, exception.StackTrace, Environment.NewLine));
                rollbackSuccessfull = Rollback();
            }
            finally
            {
                InvokeRenameFinished(new RenameFinishedEventArgs(true, renameSuccessfull, rollbackSuccessfull));
            }
        }
Beispiel #4
0
 public void RenameProjectFolder(RenameContext context)
 {
     using (SvnClient svnClient = new SvnClient())
     {
         svnClient.Move(context.OldProject.ProjectDirectory, context.NewProject.ProjectDirectory);
     }
 }
Beispiel #5
0
        public void RenameProjectFile(RenameContext context)
        {
            string oldProjectFile = string.Format("{0}{1}{2}{3}", context.NewProject.ProjectDirectory, "\\", context.OldProject.ProjectName, context.OldProject.ProjectExtension);
            string newProjectFile = string.Format("{0}{1}{2}{3}", context.NewProject.ProjectDirectory, "\\", context.NewProject.ProjectName, context.NewProject.ProjectExtension);

            if (File.Exists(oldProjectFile))
            {
                File.Move(oldProjectFile, newProjectFile);
            }
        }
Beispiel #6
0
        public void RenameMainEntryFile(RenameContext context)
        {
            string oldMainEntryFile = string.Format("{0}{1}{2}{3}", context.NewProject.ProjectDirectory, "\\", context.OldProject.ProjectName, ".cpp");
            string newMainEntryFile = string.Format("{0}{1}{2}{3}", context.NewProject.ProjectDirectory, "\\", context.NewProject.ProjectName, ".cpp");

            // Only if the main entry file in c++ projects has the same name as the project itself, move it.
            if (File.Exists(oldMainEntryFile))
            {
                using (SvnClient svnClient = new SvnClient())
                {
                    svnClient.Move(oldMainEntryFile, newMainEntryFile);
                }
            }
        }
        private void ProcessRuntimeModule()
        {
            logger.Info("Processing Runtime Module...");

            var module = ModuleDefMD.Load(Path.Combine(@"C:\Users\Nybher\Desktop\koiVM\Debug\bin", "KoiVM.Runtime.dll"));

            module.Assembly.Name += "." + User.LongID;
            module.Name           = string.Format("KoiVM.Runtime.{0}.dll", User.LongID);

            var renamer = new Renamer(random.Value.Next(), true, '#');

            renamer.Process(module);

            ctx = new RenameContext();

            ctx.VMEntry = renamer.GetNewName(ctx.VMEntry);
            ctx.VMRun   = renamer.GetNewName(ctx.VMRun);

            ctx.VMDispatcher          = renamer.GetNewName(ctx.VMDispatcher);
            ctx.VMDispatcherDothrow   = renamer.GetNewName(ctx.VMDispatcherDothrow);
            ctx.VMDispatcherThrow     = renamer.GetNewName(ctx.VMDispatcherThrow);
            ctx.VMDispatcherGetIP     = renamer.GetNewName(ctx.VMDispatcherGetIP);
            ctx.VMDispatcherStackwalk = renamer.GetNewName(ctx.VMDispatcherStackwalk);

            ctx.VMConstants = renamer.GetNewName(ctx.VMConstants);

            using (var reader = new StringReader(ctx.VMConstMapText))
            {
                while (reader.Peek() > 0)
                {
                    var line = reader.ReadLine().Trim();
                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }
                    var entry = line.Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    var key   = renamer.GetNewName(entry[0]);
                    ctx.VMConstMap.Add(Tuple.Create(key, entry[1]));
                }
            }

            random.Value.Shuffle(ctx.VMConstMap);

            using (var stream = new MemoryStream())
            {
                module.Write(stream);
                rtModule = stream.ToArray();
            }
            logger.Info("Finished Runtime Module.");
        }
Beispiel #8
0
        public void RenameProjectFiltersFile(RenameContext context)
        {
            if (!context.OldProject.ProjectType.Equals(ProjectType.Cplusplus))
            {
                return;
            }

            string oldProjectFiltersFile = string.Format("{0}{1}{2}{3}", context.NewProject.ProjectDirectory, "\\", context.OldProject.ProjectName, ".vcxproj.filters");
            string newProjectFiltersFile = string.Format("{0}{1}{2}{3}", context.NewProject.ProjectDirectory, "\\", context.NewProject.ProjectName, ".vcxproj.filters");

            if (File.Exists(oldProjectFiltersFile))
            {
                File.Move(oldProjectFiltersFile, newProjectFiltersFile);
            }
        }
Beispiel #9
0
        public bool Rollback(string solutionDirectoryPath, RenameContext context)
        {
            using (SvnClient svnClient = new SvnClient())
            {
                // TODO NKO Do someting with the changelist
                Collection <SvnListChangeListEventArgs> changeList;
                svnClient.GetChangeList(solutionDirectoryPath, out changeList);

                SvnRevertArgs revertArgs = new SvnRevertArgs {
                    Depth = SvnDepth.Infinity
                };
                svnClient.Revert(solutionDirectoryPath, revertArgs);
            }

            // Now delete the folder that was created for the new project.
            // Note: Can not use svnclient.Delete because the folder and all containing files werent ever checked in.
            Directory.Delete(context.NewProject.ProjectDirectory, true);

            // And do an update to get a clean repository state again.
            UpdateWorkingCopy(solutionDirectoryPath);

            return(true);
        }