Пример #1
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);
        }
Пример #2
0
        /// <summary>
        /// Prompts the user for a creating new script file and adds it to the
        /// project.
        /// </summary>
        private void CreateScriptFile()
        {
            var fileName = uiSvc.ShowSaveFileDialog(GetDefaultScriptPath());

            if (fileName == null)
            {
                return;
            }
            var fsSvc = sc.RequireService <IFileSystemService>();

            try
            {
                fsSvc.CopyFile(GetScriptTemplatePath(), fileName, true);
                AddScriptFile(fileName);
            }
            catch (Exception e)
            {
                uiSvc.ShowError(
                    e,
                    "An error occured while creating the script file {0}.",
                    fileName);
            }
        }