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


C# Solution.SaveAsync方法代码示例

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


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

示例1: ConfigurationsInNewProject

		public async Task ConfigurationsInNewProject ()
		{
			string dir = Util.CreateTmpDir ("ConfigurationsInNewProject");

			var sol = new Solution ();
			sol.FileName = Path.Combine (dir, "TestSolution.sln");
			sol.AddConfiguration ("Debug", true);

			var p = Services.ProjectService.CreateDotNetProject ("C#");
			p.ItemId = "{3A83F683-760F-486C-8844-B0F079B30B25}";
			p.FileName = Path.Combine (dir, "TestProject.csproj");
			sol.RootFolder.Items.Add (p);

			Assert.AreEqual (1, p.RunConfigurations.Count);
			var es = p.RunConfigurations [0];
			Assert.AreEqual ("Default", es.Name);

			await sol.SaveAsync (Util.GetMonitor ());

			Assert.IsFalse (File.Exists (p.FileName + ".user"));

			string projectXml = File.ReadAllText (p.FileName);
			string projFile = Util.GetSampleProject ("run-configurations", "ConsoleProject", "ConsoleProject.new-project.csproj");
			string newProjectXml = File.ReadAllText (projFile);
			Assert.AreEqual (Util.ToWindowsEndings (newProjectXml), projectXml);
		}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:26,代码来源:RunConfigurations.cs

示例2: CSharpFormattingPolicyIndentSwitchCaseSectionChangedMultipleTimes

		public async Task CSharpFormattingPolicyIndentSwitchCaseSectionChangedMultipleTimes ()
		{
			string dir = Util.CreateTmpDir ("IndentSwitchCaseSectionChangedMultipleTimes");
			var pset = PolicyService.GetPolicySet ("Mono");
			var monoFormattingPolicy = pset.Get<CSharpFormattingPolicy> ("text/x-csharp");
			var formattingPolicy = monoFormattingPolicy.Clone ();
			var solution = new Solution ();
			solution.Policies.Set (formattingPolicy);

			bool expectedSetting = !formattingPolicy.IndentSwitchCaseSection;
			string fileName = Path.Combine (dir, "IndentSwitchCaseSectionChangedMultipleTimes.sln");

			for (int i = 0; i < 3; ++i) {
				formattingPolicy.IndentSwitchCaseSection = expectedSetting;

				await solution.SaveAsync (fileName, Util.GetMonitor ());

				var savedSolution = (Solution)await Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), fileName);
				var savedFormattingPolicy = savedSolution.Policies.Get<CSharpFormattingPolicy> ();
				Assert.AreEqual (expectedSetting, savedFormattingPolicy.IndentSwitchCaseSection);

				expectedSetting = !expectedSetting;
			}
		}
开发者ID:kdubau,项目名称:monodevelop,代码行数:24,代码来源:PolicyTests.cs

示例3: SaveAsyncInternal

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

示例4: UpdateVersions

		/// <summary>
		/// Updates the versions.
		/// </summary>
		/// <param name="MainVersion">Main version.</param>
		/// <param name="AdditionaVersions">Additiona versions.</param>
		/// <param name="Data">Data.</param>
		/// <param name="MainSolution">Main solution.</param>
		public async static void UpdateVersions (String MainVersion, Dictionary<String,String> AdditionaVersions, SolutionVersion Data, Solution MainSolution)
		{
			
			var aProgess = new ProgressMonitor();

			if (MainSolution != null)
			{
				MainSolution.Version = MainVersion;
				await MainSolution.SaveAsync (aProgess);
			}


			if (Data != null)
			{
				///Update the version number of items that aren't synced
				var unsynceditems = from e in Data.Projects
				                    where e.SourceProject.SyncVersionWithSolution.Equals (false)
				                    select e;

				foreach (var aProj in unsynceditems.ToList())
				{
					aProj.SourceProject.Version = MainVersion;
					await aProj.SourceProject.SaveAsync(aProgess);
				}


				//now update the assmebly data
				var itemsWithAssemInfo = from e in Data.Projects
				                         where e.AssemblyVersionInfo != null
				                         select e;

				foreach (var aProj in itemsWithAssemInfo.ToList())
				{
					aProj.AssemblyVersionInfo.AssemblyVersion = new Version (MainVersion);

					aProj.AssemblyVersionInfo.Update ();
				}


				if (AdditionaVersions != null)
				{
					if (AdditionaVersions.ContainsKey ("cocoa"))
					{
						var shortVersion = AdditionaVersions ["cocoa"];

						//process iOS first
						var iOSItems = from e in Data.Projects
						               where e.AppVerisonInfo is CocoaAppVersion
						               select e;

						foreach (var aProj in iOSItems.ToList())
						{
							aProj.AppVerisonInfo.VersionOne = shortVersion;
							aProj.AppVerisonInfo.VersionTwo = MainVersion.ToString ();
							aProj.AppVerisonInfo.Update ();
						}
					}

					if (AdditionaVersions.ContainsKey ("android"))
					{
						var build = AdditionaVersions ["android"];

						var iOSItems = from e in Data.Projects
						               where e.AppVerisonInfo is AndroidAppVersion
						               select e;

						foreach (var aProj in iOSItems.ToList())
						{
							aProj.AppVerisonInfo.VersionOne = build;
							aProj.AppVerisonInfo.VersionTwo = MainVersion.ToString ();
							aProj.AppVerisonInfo.Update ();
						}
					}
				}
			}



		}
开发者ID:newky2k,项目名称:daves-monodevelop-addins,代码行数:86,代码来源:SolutionProcessor.cs

示例5: GetWrapperSolution

		//TODO: find solution that contains the project if possible
		public async Task<Solution> GetWrapperSolution (ProgressMonitor monitor, string filename)
		{
			// First of all, check if a solution with the same name already exists
			
			string solFileName = Path.ChangeExtension (filename, ".sln");
			
			if (File.Exists (solFileName)) {
				return (Solution) await Services.ProjectService.ReadWorkspaceItem (monitor, solFileName);
			}
			else {
				// Create a temporary solution and add the project to the solution
				SolutionItem sitem = await Services.ProjectService.ReadSolutionItem (monitor, filename);
				Solution tempSolution = new Solution ();
				tempSolution.FileName = solFileName;
				tempSolution.ConvertToFormat (sitem.FileFormat);
				tempSolution.RootFolder.Items.Add (sitem);
				tempSolution.CreateDefaultConfigurations ();
				await tempSolution.SaveAsync (monitor);
				return tempSolution;
			}
		}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:22,代码来源:ProjectService.cs

示例6: SaveSolutionAfterChangingCSharpFormattingPolicyForTheFirstTime

		public async Task SaveSolutionAfterChangingCSharpFormattingPolicyForTheFirstTime ()
		{
			string dir = Util.CreateTmpDir ("FormattingPolicyChangedOnce");
			var pset = PolicyService.GetPolicySet ("Mono");
			var monoFormattingPolicy = pset.Get<CSharpFormattingPolicy> ("text/x-csharp");
			var formattingPolicy = monoFormattingPolicy.Clone ();
			var solution = new Solution ();
			solution.Policies.Set (formattingPolicy);

			bool expectedSetting = !formattingPolicy.IndentSwitchCaseSection;
			formattingPolicy.IndentSwitchCaseSection = expectedSetting;
			string fileName = Path.Combine (dir, "FormattingPolicyChangedOnce.sln");

			await solution.SaveAsync (fileName, Util.GetMonitor ());

			var file = new SlnFile ();
			file.Read (fileName);
			var s = file.Sections.GetSection ("MonoDevelopProperties", SlnSectionType.PreProcess);
			var missingItem = default(KeyValuePair<string, string>);
			Assert.AreEqual (expectedSetting.ToString (), s.Properties.SingleOrDefault (p => p.Key.Contains ("IndentSwitchCaseSection")).Value);
			Assert.AreEqual (missingItem, s.Properties.SingleOrDefault (p => p.Key.Contains ("IndentSwitchSection")));
			Assert.AreEqual (missingItem, s.Properties.SingleOrDefault (p => p.Key.Contains ("IndentBlock")));
			Assert.AreEqual (missingItem, s.Properties.SingleOrDefault (p => p.Key.Contains ("SpaceBeforeDot")));
			Assert.AreEqual (missingItem, s.Properties.SingleOrDefault (p => p.Key.Contains ("NewLineForElse")));
		}
开发者ID:kdubau,项目名称:monodevelop,代码行数:25,代码来源:PolicyTests.cs

示例7: TestLoadSaveSolutionFolders

		public static async Task TestLoadSaveSolutionFolders (MSBuildFileFormat fileFormat)
		{
			List<string> ids = new List<string> ();
			
			Solution sol = new Solution ();
			sol.ConvertToFormat (fileFormat);
			string dir = Util.CreateTmpDir ("solution-folders-" + fileFormat.Name);
			sol.FileName = Path.Combine (dir, "TestSolutionFolders");
			sol.Name = "TheSolution";
			
			var p1 = Services.ProjectService.CreateDotNetProject ("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);
			
			var p2 = Services.ProjectService.CreateDotNetProject ("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);
			
			var p3 = Services.ProjectService.CreateDotNetProject ("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);
			
			var p4 = Services.ProjectService.CreateDotNetProject ("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);
			
			await sol.SaveAsync (Util.GetMonitor ());
			
			Solution sol2 = (Solution) await Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), sol.FileName);
			Assert.AreEqual (4, sol2.Items.Count);
			Assert.AreEqual (2, sol2.RootFolder.Items.Count);
			Assert.AreEqual (typeof(CSharpProject), 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(CSharpProject), 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(CSharpProject), f2.Items [0].GetType ());
			Assert.AreEqual (typeof(CSharpProject), 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:FreeBSD-DotNet,项目名称:monodevelop,代码行数:88,代码来源:TestProjectsChecks.cs

示例8: CheckGenericItemProject

		public static async Task CheckGenericItemProject (MSBuildFileFormat format)
		{
			Solution sol = new Solution ();
			sol.ConvertToFormat (format);
			string dir = Util.CreateTmpDir ("generic-item-" + format.Name);
			sol.FileName = Path.Combine (dir, "TestGenericItem");
			sol.Name = "TheItem";

			MonoDevelop.Projects.MSBuild.MSBuildProjectService.RegisterGenericProjectType ("GenericItem", typeof(GenericItem));
			
			GenericItem it = new GenericItem ();
			it.SomeValue = "hi";
			
			sol.RootFolder.Items.Add (it);
			it.FileName = Path.Combine (dir, "TheItem");
			it.Name = "TheItem";
			
			await sol.SaveAsync (Util.GetMonitor ());
			
			Solution sol2 = (Solution) await Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), sol.FileName);
			Assert.AreEqual (1, sol2.Items.Count);
			Assert.IsInstanceOf<GenericItem> (sol2.Items [0]);
			
			it = (GenericItem) sol2.Items [0];
			Assert.AreEqual ("hi", it.SomeValue);
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:26,代码来源:TestProjectsChecks.cs


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