public string CreateEntry(ProjectCreateInformation projectCreateInformation, string defaultLanguage) { Combine newCombine = new Combine(); string newCombineName = Runtime.StringParserService.Parse(name, new string[,] { {"ProjectName", projectCreateInformation.ProjectName} }); newCombine.Name = newCombineName; string oldCombinePath = projectCreateInformation.CombinePath; string oldProjectPath = projectCreateInformation.ProjectBasePath; if (relativeDirectory != null && relativeDirectory.Length > 0 && relativeDirectory != ".") { projectCreateInformation.CombinePath = projectCreateInformation.CombinePath + Path.DirectorySeparatorChar + relativeDirectory; projectCreateInformation.ProjectBasePath = projectCreateInformation.CombinePath + Path.DirectorySeparatorChar + relativeDirectory; if (!Directory.Exists(projectCreateInformation.CombinePath)) { Directory.CreateDirectory(projectCreateInformation.CombinePath); } if (!Directory.Exists(projectCreateInformation.ProjectBasePath)) { Directory.CreateDirectory(projectCreateInformation.ProjectBasePath); } } // Create sub projects foreach (ICombineEntryDescriptor entryDescriptor in entryDescriptors) { newCombine.AddEntry (entryDescriptor.CreateEntry (projectCreateInformation, defaultLanguage), null); } projectCreateInformation.CombinePath = oldCombinePath; projectCreateInformation.ProjectBasePath = oldProjectPath; // Save combine using (IProgressMonitor monitor = Runtime.TaskService.GetSaveProgressMonitor ()) { string combineLocation = Runtime.FileUtilityService.GetDirectoryNameWithSeparator(projectCreateInformation.CombinePath) + newCombineName + ".mds"; if (File.Exists(combineLocation)) { IMessageService messageService =(IMessageService)ServiceManager.GetService(typeof(IMessageService)); if (messageService.AskQuestion(String.Format (GettextCatalog.GetString ("Solution file {0} already exists, do you want to overwrite\nthe existing file ?"), combineLocation))) { newCombine.Save (combineLocation, monitor); } } else { newCombine.Save (combineLocation, monitor); } newCombine.Dispose(); return combineLocation; } }
void backgroundLoadCombine(object arg) { object[] data = (object[]) arg; string filename = data[0] as string; IProgressMonitor monitor = data [1] as IProgressMonitor; try { if (!fileUtilityService.TestFileExists(filename)) { monitor.ReportError (string.Format (GettextCatalog.GetString ("File not found: {0}"), filename), null); return; } string validcombine = Path.ChangeExtension (filename, ".mds"); if (Path.GetExtension (filename).ToLower() != ".mds") { if (File.Exists (validcombine)) filename = validcombine; } else if (Path.GetExtension (filename).ToLower () != ".cmbx") { if (File.Exists (Path.ChangeExtension (filename, ".cmbx"))) filename = Path.ChangeExtension (filename, ".cmbx"); } CombineEntry entry = ReadFile (filename, monitor); if (!(entry is Combine)) { Combine loadingCombine = new Combine(); loadingCombine.Entries.Add (entry); loadingCombine.Name = entry.Name; loadingCombine.Save (validcombine, monitor); entry = loadingCombine; } openCombine = (Combine) entry; Runtime.FileService.RecentOpen.AddLastProject (filename, openCombine.Name); openCombine.FileAddedToProject += new ProjectFileEventHandler (NotifyFileAddedToProject); openCombine.FileRemovedFromProject += new ProjectFileEventHandler (NotifyFileRemovedFromProject); openCombine.FileRenamedInProject += new ProjectFileRenamedEventHandler (NotifyFileRenamedInProject); openCombine.FileChangedInProject += new ProjectFileEventHandler (NotifyFileChangedInProject); openCombine.ReferenceAddedToProject += new ProjectReferenceEventHandler (NotifyReferenceAddedToProject); openCombine.ReferenceRemovedFromProject += new ProjectReferenceEventHandler (NotifyReferenceRemovedFromProject); SearchForNewFiles (); parserDatabase.Load (openCombine); OnCombineOpened (new CombineEventArgs(openCombine)); Runtime.DispatchService.GuiDispatch (new StatefulMessageHandler (RestoreCombinePreferences), CurrentOpenCombine); SaveCombine (); monitor.ReportSuccess (GettextCatalog.GetString ("Combine loaded.")); } catch (Exception ex) { monitor.ReportError ("Load operation failed.", ex); } finally { monitor.Dispose (); } }