예제 #1
0
        public void Sud_SaveMetadataReference()
        {
            var project = new Project
            {
                Programs =
                {
                    new Program
                    {
                        Filename = "c:\\test\\foo.exe",
                    }
                },
                MetadataFiles =
                {
                    new MetadataFile
                    {
                        Filename   = "c:\\test\\foo.def",
                        ModuleName = "foo.def",
                    }
                }
            };
            var ps       = new ProjectSaver();
            var sProject = ps.Save(project);

            Assert.AreEqual(1, project.MetadataFiles.Count);
            Assert.AreEqual("c:\\test\\foo.def", project.MetadataFiles[0].Filename);
            Assert.AreEqual("foo.def", project.MetadataFiles[0].ModuleName);
        }
예제 #2
0
        /// <summary>
        /// Saves the project.
        /// </summary>
        /// <returns>False if the user cancelled the save, true otherwise.</returns>
        public bool Save()
        {
            if (decompilerSvc.Decompiler == null)
            {
                return(true);
            }
            if (string.IsNullOrEmpty(this.ProjectFileName))
            {
                string newName = uiSvc.ShowSaveFileDialog(
                    Path.ChangeExtension(
                        decompilerSvc.Decompiler.Project.Programs[0].Filename,
                        Project_v3.FileExtension));
                if (newName == null)
                {
                    return(false);
                }
                ProjectFileName = newName;
                RememberFilenameInMru(newName);
            }

            var fsSvc    = Services.RequireService <IFileSystemService>();
            var saver    = new ProjectSaver(sc);
            var sProject = saver.Serialize(ProjectFileName, decompilerSvc.Decompiler.Project);

            using (var xw = fsSvc.CreateXmlWriter(ProjectFileName))
            {
                saver.Save(sProject, xw);
            }
            return(true);
        }
예제 #3
0
        private void ProjectFormClosing(object sender, FormClosingEventArgs e)
        {
            if (IsSaveRequired)
            {
                var dialogResult = MessageBox.Show(
                    "The project has been changed. Do you want to save the changes?",
                    "Save project",
                    MessageBoxButtons.YesNoCancel,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button3);

                if (dialogResult == DialogResult.Yes)
                {
                    var result = ProjectSaver.Save(Project);

                    DialogResult = result.Item1;
                    Project      = result.Item2;
                }

                if (dialogResult == DialogResult.Cancel || DialogResult == DialogResult.Cancel)
                {
                    e.Cancel = true;
                    return; //don't dispose
                }
            }

            _disposables.Dispose();
        }
예제 #4
0
        public void Sud_SaveMetadataReference()
        {
            Given_Architecture();
            Given_TestOS_Platform();
            var project = new Project
            {
                Programs =
                {
                    new Program
                    {
                        Architecture = arch,
                        Platform     = platform,
                        Filename     = "c:\\test\\foo.exe",
                    }
                },
                MetadataFiles =
                {
                    new MetadataFile
                    {
                        Filename   = "c:\\test\\foo.def",
                        ModuleName = "foo.def",
                    }
                }
            };

            mr.ReplayAll();

            var ps       = new ProjectSaver(sc);
            var sProject = ps.Save("c:\\test\\foo.project", project);

            Assert.AreEqual(1, project.MetadataFiles.Count);
            Assert.AreEqual("c:\\test\\foo.def", project.MetadataFiles[0].Filename);
            Assert.AreEqual("foo.def", project.MetadataFiles[0].ModuleName);
        }
예제 #5
0
        static void Main(String[] args)
        {
            ProjectDef projectDef = DefineProject();

            ProjectSaver.Save(projectDef, "D:/Temporary/Luminary");

            ProjectLoader loader           = new ProjectLoader();
            ProjectDef    projectDefLoaded = loader.Load(@"D:/Temporary/Luminary/Test.json");
        }
예제 #6
0
        private void BtnCreateNewProjectClick(object sender, EventArgs e)
        {
            var result = ProjectSaver.Save();

            DialogResult = result.Item1;
            Project      = result.Item2;

            if (DialogResult == DialogResult.OK && Project != null)
            {
                Close();
            }
        }
예제 #7
0
        public void Save_ProjectWithoutAssemblyVersion_ShouldSaveVersionOnly()
        {
            var testProject = TestPathHelper.GetTestProjectPath("TO_MODIFY");
            var newPatch    = Convert.ToInt32((DateTime.Now - DateTime.Today).TotalSeconds);
            var project     = new Project("TO_MODIFY", new Version(1, 1, newPatch, ""),
                                          Option <AssemblyVersion> .None, testProject);

            ProjectSaver.Save(project);

            var savedVersion            = $"1.1.{newPatch}";
            var notSavedAssemblyVersion = $"1.1.{newPatch}.0";

            NodeFinder.GetVersionNodeValue(testProject, VersionNode.Version).ShouldBe(savedVersion);
            NodeFinder.GetVersionNodeValue(testProject, VersionNode.AssemblyVersion).ShouldNotBe(notSavedAssemblyVersion);
        }
예제 #8
0
        private void BtnLoadProjectClick(object sender, EventArgs e)
        {
            var projectTask = ProjectLoader.Load(ToggleFormState);

            projectTask.ContinueWith(
                antecedent =>
            {
                Project = antecedent.Result;

                DialogResult = DialogResult.OK;
                Close();
            },
                CancellationToken.None,
                TaskContinuationOptions.OnlyOnRanToCompletion,
                TaskScheduler.FromCurrentSynchronizationContext());

            projectTask.ContinueWith(
                antecedent =>
            {
                DialogResult = MessageBox.Show(
                    "An error occured while reading the project file, continue with an empty project?",
                    "Error retriving the project details",
                    MessageBoxButtons.OKCancel,
                    MessageBoxIcon.Error,
                    MessageBoxDefaultButton.Button2);

                if (DialogResult == DialogResult.OK)
                {
                    var result = ProjectSaver.Save();

                    DialogResult = result.Item1;
                    Project      = result.Item2;
                }

                if (DialogResult == DialogResult.OK && Project != null)
                {
                    Close();
                }
            },
                CancellationToken.None,
                TaskContinuationOptions.OnlyOnCanceled,
                TaskScheduler.FromCurrentSynchronizationContext());
        }