当前位置: 首页>>代码示例>>C#>>正文


C# Solution.Save方法代码示例

本文整理汇总了C#中Solution.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Solution.Save方法的具体用法?C# Solution.Save怎么用?C# Solution.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Solution的用法示例。


在下文中一共展示了Solution.Save方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddNewProjectToSolution

			/// <summary>
			/// Creates a new project and adds it to the current solution
			/// </summary>
			public static Project AddNewProjectToSolution(Solution sln, AbstractLanguageBinding Binding, FileTemplate ProjectType, string Name, string BaseDir)
			{
				var prj = CreateNewProject(Binding, ProjectType, Name, BaseDir);
				if (prj != null)
				{
					prj.Save();
					sln.AddProject(prj);
					sln.Save();
				}

				Instance.UpdateGUI();
				return prj;
			}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:16,代码来源:ProjectManagement.cs

示例2: Save

		public void Save (Solution item)
		{
			if (!item.FileFormat.CanWrite (item)) {
				if (!SelectValidFileFormat (item))
					return;
			}
			
			if (!AllowSave (item))
				return;
			
			IProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetSaveProgressMonitor (true);
			try {
				item.Save (monitor);
				monitor.ReportSuccess (GettextCatalog.GetString ("Solution saved."));
			} catch (Exception ex) {
				monitor.ReportError (GettextCatalog.GetString ("Save failed."), ex);
			} finally {
				monitor.Dispose ();
			}
		}
开发者ID:nocache,项目名称:monodevelop,代码行数:20,代码来源:ProjectOperations.cs

示例3: GetWrapperSolution

		public Solution GetWrapperSolution (IProgressMonitor monitor, string filename)
		{
			// First of all, check if a solution with the same name already exists
			
			FileFormat[] formats = Services.ProjectService.FileFormats.GetFileFormats (filename, typeof(SolutionEntityItem));
			if (formats.Length == 0)
				formats = new FileFormat [] { DefaultFileFormat };
			
			Solution tempSolution = new Solution ();
			
			FileFormat solutionFileFormat;
			if (formats [0].CanWrite (tempSolution))
				solutionFileFormat = formats [0];
			else
				solutionFileFormat = MonoDevelop.Projects.Formats.MD1.MD1ProjectService.FileFormat;
			
			string solFileName = solutionFileFormat.GetValidFileName (tempSolution, filename);
			
			if (File.Exists (solFileName)) {
				return (Solution) Services.ProjectService.ReadWorkspaceItem (monitor, solFileName);
			}
			else {
				// Create a temporary solution and add the project to the solution
				tempSolution.SetLocation (Path.GetDirectoryName (filename), Path.GetFileNameWithoutExtension (filename));
				SolutionEntityItem sitem = Services.ProjectService.ReadSolutionItem (monitor, filename);
				tempSolution.ConvertToFormat (solutionFileFormat, false);
				tempSolution.RootFolder.Items.Add (sitem);
				tempSolution.CreateDefaultConfigurations ();
				tempSolution.Save (monitor);
				return tempSolution;
			}
		}
开发者ID:hduregger,项目名称:monodevelop,代码行数:32,代码来源:ProjectService.cs

示例4: TestLoadSaveSolutionFolders

		public static void TestLoadSaveSolutionFolders (string fileFormat)
		{
			List<string> ids = new List<string> ();
			
			Solution sol = new Solution ();
			sol.ConvertToFormat (Services.ProjectService.FileFormats.GetFileFormat (fileFormat), true);
			string dir = Util.CreateTmpDir ("solution-folders-" + fileFormat);
			sol.FileName = Path.Combine (dir, "TestSolutionFolders");
			sol.Name = "TheSolution";
			
			DotNetAssemblyProject p1 = new DotNetAssemblyProject ("C#");
			p1.FileName = Path.Combine (dir, "p1");
			sol.RootFolder.Items.Add (p1);
			string idp1 = p1.ItemId;
			Assert.IsFalse (string.IsNullOrEmpty (idp1));
			Assert.IsFalse (ids.Contains (idp1));
			ids.Add (idp1);

			SolutionFolder f1 = new SolutionFolder ();
			f1.Name = "f1";
			sol.RootFolder.Items.Add (f1);
			string idf1 = f1.ItemId;
			Assert.IsFalse (string.IsNullOrEmpty (idf1));
			Assert.IsFalse (ids.Contains (idf1));
			ids.Add (idf1);
			
			DotNetAssemblyProject p2 = new DotNetAssemblyProject ("C#");
			p2.FileName = Path.Combine (dir, "p2");
			f1.Items.Add (p2);
			string idp2 = p2.ItemId;
			Assert.IsFalse (string.IsNullOrEmpty (idp2));
			Assert.IsFalse (ids.Contains (idp2));
			ids.Add (idp2);

			SolutionFolder f2 = new SolutionFolder ();
			f2.Name = "f2";
			f1.Items.Add (f2);
			string idf2 = f2.ItemId;
			Assert.IsFalse (string.IsNullOrEmpty (idf2));
			Assert.IsFalse (ids.Contains (idf2));
			ids.Add (idf2);
			
			DotNetAssemblyProject p3 = new DotNetAssemblyProject ("C#");
			p3.FileName = Path.Combine (dir, "p3");
			f2.Items.Add (p3);
			string idp3 = p3.ItemId;
			Assert.IsFalse (string.IsNullOrEmpty (idp3));
			Assert.IsFalse (ids.Contains (idp3));
			ids.Add (idp3);
			
			DotNetAssemblyProject p4 = new DotNetAssemblyProject ("C#");
			p4.FileName = Path.Combine (dir, "p4");
			f2.Items.Add (p4);
			string idp4 = p4.ItemId;
			Assert.IsFalse (string.IsNullOrEmpty (idp4));
			Assert.IsFalse (ids.Contains (idp4));
			ids.Add (idp4);
			
			sol.Save (Util.GetMonitor ());
			
			Solution sol2 = (Solution) Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), sol.FileName);
			Assert.AreEqual (4, sol2.Items.Count);
			Assert.AreEqual (2, sol2.RootFolder.Items.Count);
			Assert.AreEqual (typeof(DotNetAssemblyProject), sol2.RootFolder.Items [0].GetType ());
			Assert.AreEqual (typeof(SolutionFolder), sol2.RootFolder.Items [1].GetType ());
			Assert.AreEqual ("p1", sol2.RootFolder.Items [0].Name);
			Assert.AreEqual ("f1", sol2.RootFolder.Items [1].Name);
			Assert.AreEqual (idp1, sol2.RootFolder.Items [0].ItemId, "idp1");
			Assert.AreEqual (idf1, sol2.RootFolder.Items [1].ItemId, "idf1");
			
			f1 = (SolutionFolder) sol2.RootFolder.Items [1];
			Assert.AreEqual (2, f1.Items.Count);
			Assert.AreEqual (typeof(DotNetAssemblyProject), f1.Items [0].GetType ());
			Assert.AreEqual (typeof(SolutionFolder), f1.Items [1].GetType ());
			Assert.AreEqual ("p2", f1.Items [0].Name);
			Assert.AreEqual ("f2", f1.Items [1].Name);
			Assert.AreEqual (idp2, f1.Items [0].ItemId, "idp2");
			Assert.AreEqual (idf2, f1.Items [1].ItemId, "idf2");
			
			f2 = (SolutionFolder) f1.Items [1];
			Assert.AreEqual (2, f2.Items.Count);
			Assert.AreEqual (typeof(DotNetAssemblyProject), f2.Items [0].GetType ());
			Assert.AreEqual (typeof(DotNetAssemblyProject), f2.Items [1].GetType ());
			Assert.AreEqual ("p3", f2.Items [0].Name);
			Assert.AreEqual ("p4", f2.Items [1].Name);
			Assert.AreEqual (idp3, f2.Items [0].ItemId, "idp4");
			Assert.AreEqual (idp4, f2.Items [1].ItemId, "idp4");
		}
开发者ID:segaman,项目名称:monodevelop,代码行数:88,代码来源:TestProjectsChecks.cs

示例5: CheckGenericItemProject

		public static void CheckGenericItemProject (string fileFormat)
		{
			Solution sol = new Solution ();
			sol.ConvertToFormat (Services.ProjectService.FileFormats.GetFileFormat (fileFormat), true);
			string dir = Util.CreateTmpDir ("generic-item-" + fileFormat);
			sol.FileName = Path.Combine (dir, "TestGenericItem");
			sol.Name = "TheItem";
			
			GenericItem it = new GenericItem ();
			it.SomeValue = "hi";
			
			sol.RootFolder.Items.Add (it);
			it.FileName = Path.Combine (dir, "TheItem");
			it.Name = "TheItem";
			
			sol.Save (Util.GetMonitor ());
			
			Solution sol2 = (Solution) Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), sol.FileName);
			Assert.AreEqual (1, sol2.Items.Count);
			Assert.IsTrue (sol2.Items [0] is GenericItem);
			
			it = (GenericItem) sol2.Items [0];
			Assert.AreEqual ("hi", it.SomeValue);
		}
开发者ID:segaman,项目名称:monodevelop,代码行数:24,代码来源:TestProjectsChecks.cs

示例6: SetupSolution

        static bool SetupSolution(Solution newSolution)
        {
            ProjectSection nestedProjectsSection = null;

            // read solution files using system encoding, but detect UTF8 if BOM is present
            using (StreamReader sr = new StreamReader(newSolution.FileName, Encoding.Default, true)) {
                string line = GetFirstNonCommentLine(sr);
                Match match = versionPattern.Match(line);
                if (!match.Success) {
                    MessageService.ShowErrorFormatted("${res:SharpDevelop.Solution.InvalidSolutionFile}", newSolution.FileName);
                    return false;
                }

                switch (match.Result("${Version}")) {
                    case "7.00":
                    case "8.00":
                        MessageService.ShowError("${res:SharpDevelop.Solution.CannotLoadOldSolution}");
                        return false;
                    case "9.00":
                    case "10.00":
                    case "11.00":
                        break;
                    default:
                        MessageService.ShowErrorFormatted("${res:SharpDevelop.Solution.UnknownSolutionVersion}", match.Result("${Version}"));
                        return false;
                }

                using (AsynchronousWaitDialog waitDialog = AsynchronousWaitDialog.ShowWaitDialog("Loading solution")) {
                    nestedProjectsSection = SetupSolutionLoadSolutionProjects(newSolution, sr, waitDialog);
                }
            }
            // Create solution folder 'tree'.
            if (nestedProjectsSection != null) {
                foreach (SolutionItem item in nestedProjectsSection.Items) {
                    string from = item.Name;
                    string to   = item.Location;
                    if (newSolution.guidDictionary.ContainsKey(to) && newSolution.guidDictionary.ContainsKey(from)) {
                        // ignore invalid entries

                        ISolutionFolderContainer folder = newSolution.guidDictionary[to] as ISolutionFolderContainer;
                        folder.AddFolder(newSolution.guidDictionary[from]);
                    }
                }
            }

            if (!newSolution.ReadOnly && (newSolution.FixSolutionConfiguration(newSolution.Projects))) {
                // save in new format
                newSolution.Save();
            }
            return true;
        }
开发者ID:uluhonolulu,项目名称:Chpokk,代码行数:51,代码来源:Solution.cs

示例7: GenerateSolution

        void GenerateSolution()
        {
            var solution = new Solution {
                Name = projectName
            };

            var progressMonitor = new SimpleProgressMonitor ();
            var solutionPath = Path.Combine (rootFolder, projectName, solution.Name);

            foreach (var target in xcodeProjectModel.Targets) {
                var projectPath = Path.Combine (rootFolder, projectName, target.Name, target.Name + ".csproj");
                var project = Project.LoadProject (projectPath, progressMonitor);
                solution.RootFolder.AddItem (project);
            }

            solution.AddConfiguration ("Debug|iPhoneSimulator", true);
            solution.AddConfiguration ("Release|iPhoneSimulator", true);
            solution.AddConfiguration ("Debug|iPhone", true);
            solution.AddConfiguration ("Release|iPhone", true);
            solution.AddConfiguration ("Ad-Hoc|iPhone", true);
            solution.AddConfiguration ("AppStore|iPhone", true);

            solution.Save (solutionPath, progressMonitor);
            IdeApp.Workspace.OpenWorkspaceItem (solutionPath + ".sln");
        }
开发者ID:newky2k,项目名称:sample-translator,代码行数:25,代码来源:SolutionGenerator.cs

示例8: Convert

		static void Convert(Solution newSolution, List<string> projectFiles)
		{
			PrjxToSolutionProject.Conversion conversion = new PrjxToSolutionProject.Conversion();
			
			foreach (string path in projectFiles) {
				string name = PrjxToSolutionProject.Conversion.GetProjectName(path);
				conversion.NameToGuid[name] = Guid.NewGuid();
				if (IsVisualBasic(path))
					conversion.NameToPath[name] = Path.ChangeExtension(path, ".vbproj");
				else
					conversion.NameToPath[name] = Path.ChangeExtension(path, ".csproj");
			}
			foreach (string path in projectFiles) {
				conversion.IsVisualBasic = IsVisualBasic(path);
				IProject newProject = PrjxToSolutionProject.ConvertOldProject(path, conversion, newSolution);
				newSolution.AddFolder(newProject);
			}
			if (conversion.Resources != null) {
				const string resourceWarning = "${res:SharpDevelop.Solution.ImportResourceWarning}";
				if (conversion.Resources.Count == 0) {
					MessageService.ShowMessage(resourceWarning);
				} else {
					StringBuilder txt = new StringBuilder(resourceWarning);
					txt.AppendLine();
					txt.AppendLine();
					txt.AppendLine("${res:SharpDevelop.Solution.ImportResourceWarningErrorText}");
					foreach (string r in conversion.Resources)
						txt.AppendLine(r);
					MessageService.ShowMessage(txt.ToString());
				}
			}
			newSolution.Save();
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:33,代码来源:CombineToSolution.cs

示例9: CreateProject

        void CreateProject(Solution solution, SolutionFolder srcFolder, bool newSolution = true)
        {
            string projectName = Parameters["UserDefinedProjectName"];
            DnxProject project = CreateProject (solution, projectName);
            srcFolder.AddItem (project);

            project.AddConfigurations ();

            if (newSolution) {
                solution.GenerateDefaultDnxProjectConfigurations (project);
                solution.StartupItem = project;
            } else {
                solution.EnsureConfigurationHasBuildEnabled (project);
            }

            project.CreateProjectDirectory ();

            if (Parameters.GetBoolean ("CreateWebRoot")) {
                project.CreateWebRootDirectory ();
            }

            RemoveProjectDirectoryCreatedByNewProjectDialog (solution.BaseDirectory, projectName);

            CreateFilesFromTemplate (project);

            solution.Save (new NullProgressMonitor ());

            OpenProjectFile (project);

            DnxServices.ProjectService.LoadAspNetProjectSystem (solution);
        }
开发者ID:lordfinal,项目名称:monodevelop-dnx-addin,代码行数:31,代码来源:DnxProjectTemplateWizard.cs

示例10: AddExistingProjectToSolution

			public static bool AddExistingProjectToSolution(Solution sln, string Projectfile)
			{
				/*
				 * a) Check if project already existing
				 * b) Add to solution; if succeeded:
				 * c) Try to load project; if succeeded:
				 * d) Save solution
				 */

				// a)
				if (sln.ContainsProject(Projectfile))
				{
					MessageBox.Show("Project" + sln[Projectfile].Name + " is already part of solution "+sln.Name, "Project addition error");
					return false;
				}
				// b)
				if (!sln.AddProject(Projectfile))
					return false;
				// c)
				var prj = Project.LoadProjectFromFile(sln, Projectfile);
				if (prj == null) return false; // Perhaps it's a project format that's simply not supported

				// d)
				sln.Save();

				Instance.UpdateGUI();
				return true;
			}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:28,代码来源:ProjectManagement.cs

示例11: ExcludeProject

			/// <summary>
			/// (Since we don't want to remove a whole project we still can exclude them from solutions)
			/// </summary>
			public static void ExcludeProject(Solution sln, string prjFile)
			{
				/*
				 * - Remove reference from solution
				 * - Save solution
				 */

				sln.ExcludeProject(prjFile);
				sln.Save();

				Instance.UpdateGUI();
			}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:15,代码来源:ProjectManagement.cs

示例12: Rename

			public static bool Rename(Solution sln, string NewName)
			{
				// Prevent moving the project into an other directory
				if (String.IsNullOrEmpty(NewName) || NewName.Contains('\\'))
					return false;

				/*
				 * - Try to rename the solution file
				 * - Rename the solution
				 * - Save it
				 */

				var newSolutionFileName = Path.ChangeExtension(Util.PurifyFileName(NewName), Solution.SolutionExtension);
				var ret = Util.MoveFile(sln.FileName, newSolutionFileName);
				if (ret)
				{
					sln.Name = NewName;
					sln.FileName = sln.BaseDirectory + "\\" + newSolutionFileName;
					Instance.MainWindow.RefreshTitle();
					sln.Save();
				}
				return ret;
			}
开发者ID:DinrusGroup,项目名称:D-IDE,代码行数:23,代码来源:ProjectManagement.cs

示例13: Save

 public void Save(Solution solution)
 {
     solution.Save();
 }
开发者ID:eswarpr,项目名称:monodevelop-nuget-addin,代码行数:4,代码来源:PackageManagementProjectService.cs


注:本文中的Solution.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。