當前位置: 首頁>>代碼示例>>C#>>正文


C# Workspace.GetConfigurations方法代碼示例

本文整理匯總了C#中MonoDevelop.Projects.Workspace.GetConfigurations方法的典型用法代碼示例。如果您正苦於以下問題:C# Workspace.GetConfigurations方法的具體用法?C# Workspace.GetConfigurations怎麽用?C# Workspace.GetConfigurations使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MonoDevelop.Projects.Workspace的用法示例。


在下文中一共展示了Workspace.GetConfigurations方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Configurations

		public void Configurations ()
		{
			int configChangedEvs = 0;
			int configChangedEvsSub = 0;
			
			Workspace ws = new Workspace ();
			ws.ConfigurationsChanged += delegate { configChangedEvs++; };

			Workspace cws1 = new Workspace ();
			cws1.ConfigurationsChanged += delegate { configChangedEvsSub++; };
			ws.Items.Add (cws1);
			
			Solution sol = new Solution ();
			cws1.Items.Add (sol);
			
			ReadOnlyCollection<string> configs = ws.GetConfigurations ();
			Assert.AreEqual (0, configs.Count);
			configs = cws1.GetConfigurations ();
			Assert.AreEqual (0, configs.Count);
			
			// Add configurations
			
			configChangedEvs = configChangedEvsSub = 0;
			sol.AddConfiguration ("c1", false);
			Assert.AreEqual (1, configChangedEvs);
			Assert.AreEqual (1, configChangedEvsSub);
			
			configs = ws.GetConfigurations ();
			Assert.AreEqual (1, configs.Count);
			Assert.AreEqual ("c1", configs[0]);
			configs = cws1.GetConfigurations ();
			Assert.AreEqual (1, configs.Count);
			Assert.AreEqual ("c1", configs[0]);
			
			configChangedEvs = configChangedEvsSub = 0;
			sol.AddConfiguration ("c2", false);
			Assert.AreEqual (1, configChangedEvs);
			Assert.AreEqual (1, configChangedEvsSub);
			
			configs = ws.GetConfigurations ();
			Assert.AreEqual (2, configs.Count);
			Assert.AreEqual ("c1", configs[0]);
			Assert.AreEqual ("c2", configs[1]);
			configs = cws1.GetConfigurations ();
			Assert.AreEqual (2, configs.Count);
			Assert.AreEqual ("c1", configs[0]);
			Assert.AreEqual ("c2", configs[1]);

			// Add another solution
			
			Solution sol2 = new Solution ();
			sol2.AddConfiguration ("c3", false);
			sol2.AddConfiguration ("c4", false);
			
			configChangedEvs = configChangedEvsSub = 0;
			cws1.Items.Add (sol2);
			Assert.AreEqual (1, configChangedEvs);
			Assert.AreEqual (1, configChangedEvsSub);
			
			configs = ws.GetConfigurations ();
			Assert.AreEqual (4, configs.Count);
			Assert.AreEqual ("c1", configs[0]);
			Assert.AreEqual ("c2", configs[1]);
			Assert.AreEqual ("c3", configs[2]);
			Assert.AreEqual ("c4", configs[3]);
			configs = cws1.GetConfigurations ();
			Assert.AreEqual (4, configs.Count);
			Assert.AreEqual ("c1", configs[0]);
			Assert.AreEqual ("c2", configs[1]);
			Assert.AreEqual ("c3", configs[2]);
			Assert.AreEqual ("c4", configs[3]);
			
			// Remove solution
			
			configChangedEvs = configChangedEvsSub = 0;
			cws1.Items.Remove (sol2);
			Assert.AreEqual (1, configChangedEvs);
			Assert.AreEqual (1, configChangedEvsSub);
			
			configs = ws.GetConfigurations ();
			Assert.AreEqual (2, configs.Count);
			Assert.AreEqual ("c1", configs[0]);
			Assert.AreEqual ("c2", configs[1]);
			configs = cws1.GetConfigurations ();
			Assert.AreEqual (2, configs.Count);
			Assert.AreEqual ("c1", configs[0]);
			Assert.AreEqual ("c2", configs[1]);
			
			// Remove configuration
			
			configChangedEvs = configChangedEvsSub = 0;
			sol.Configurations.RemoveAt (1);
			Assert.AreEqual (1, configChangedEvs);
			Assert.AreEqual (1, configChangedEvsSub);

			configs = ws.GetConfigurations ();
			Assert.AreEqual (1, configs.Count);
			Assert.AreEqual ("c1", configs[0]);
			configs = cws1.GetConfigurations ();
			Assert.AreEqual (1, configs.Count);
//.........這裏部分代碼省略.........
開發者ID:pabloescribanoloza,項目名稱:monodevelop,代碼行數:101,代碼來源:WorkspaceTests.cs


注:本文中的MonoDevelop.Projects.Workspace.GetConfigurations方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。