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


C# Solution.FindProjectByName方法代码示例

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


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

示例1: Setup

		public override void Setup ()
		{
			base.Setup ();
			string solFile = Util.GetSampleProject ("completion-db-test", "CompletionDbTest.sln");
			solution = (Solution) Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), solFile);
			ProjectDomService.Load (solution);

			Project prj;
			prj = solution.FindProjectByName ("Library2");
			lib2 = ProjectDomService.GetProjectDom (prj);
			lib2.ForceUpdate (true);
			prj = solution.FindProjectByName ("Library1");
			lib1 = ProjectDomService.GetProjectDom (prj);
			lib1.ForceUpdate (true);
			prj = solution.FindProjectByName ("CompletionDbTest");
			mainProject = ProjectDomService.GetProjectDom (prj);
			mainProject.ForceUpdate (true);
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:18,代码来源:CompletionDatabaseTests.cs

示例2: CheckProjectReferencesBuildClean

		void CheckProjectReferencesBuildClean (Solution sol, string configuration)
		{
			SolutionConfigurationSelector config = (SolutionConfigurationSelector) configuration;
			string tag = "CheckProjectReferencesBuildClean config=" + configuration;
			DotNetProject lib1 = (DotNetProject) sol.FindProjectByName ("Lib1");
			DotNetProject lib2 = (DotNetProject) sol.FindProjectByName ("Lib2");
			DotNetProject lib3 = (DotNetProject) sol.FindProjectByName ("Lib3");
			DotNetProject lib4 = (DotNetProject) sol.FindProjectByName ("Lib4");
			
			Assert.IsFalse (File.Exists (lib1.GetOutputFileName (config)), tag);
			Assert.IsFalse (File.Exists (lib2.GetOutputFileName (config)), tag);
			Assert.IsFalse (File.Exists (lib3.GetOutputFileName (config)), tag);
			Assert.IsFalse (File.Exists (lib4.GetOutputFileName (config)), tag);
			
			BuildResult res = lib1.Build (Util.GetMonitor (), config, true);
			Assert.AreEqual (0, res.WarningCount, tag);
			Assert.AreEqual (0, res.ErrorCount, tag + " " + res.CompilerOutput);
			
			Assert.IsTrue (File.Exists (lib1.GetOutputFileName (config)), tag);
			Assert.IsTrue (File.Exists (lib2.GetOutputFileName (config)), tag);
			Assert.IsTrue (File.Exists (lib3.GetOutputFileName (config)), tag);
			Assert.IsTrue (File.Exists (lib4.GetOutputFileName (config)), tag);
			
			sol.Clean (Util.GetMonitor (), config);
		}
开发者ID:segaman,项目名称:monodevelop,代码行数:25,代码来源:SolutionTests.cs

示例3: ResolveProject

		/// <summary>
		/// Resolves a project for a ReferenceType.Project reference type in a given solution.
		/// </summary>
		/// <returns>The project, or <c>null</c> if it couldn't be resolved.</returns>
		/// <param name="inSolution">The solution the project is in.</param>
		/// <exception cref="T:System.ArgumentNullException">Thrown if inSolution == null</exception>
		/// <exception cref="T:System.InvalidOperationException">Thrown if ReferenceType != ReferenceType.Project</exception>
		public Project ResolveProject (Solution inSolution)
		{
			if (inSolution == null)
				throw new ArgumentNullException ("inSolution");
			if (ReferenceType != ReferenceType.Project)
				throw new InvalidOperationException ("ResolveProject is only definied for Project reference type.");
			return inSolution.FindProjectByName (Reference);
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:15,代码来源:ProjectReference.cs

示例4: AddXwtFromGithubAsync

		async Task AddXwtFromGithubAsync (Solution solution, string newProjectName, bool createSubmodule, ProgressMonitor monitor)
		{
			try {
				var gitUrl = "https://github.com/" + (string.IsNullOrEmpty (Parameters ["XwtGithubRepository"]) ? Parameters ["XwtGithubRepository"] : "mono/xwt") + ".git";
				var gitBranch = Parameters ["XwtGithubBranch"];
				if (gitBranch == String.Empty)
					gitBranch = "master";
				var gitRepo = VersionControlService.GetRepository (solution) as GitRepository;
				var xwt_proj = solution.FindProjectByName ("Xwt") as DotNetProject;

				if (xwt_proj != null && xwt_proj.ItemId.ToUpper () != "{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}") {
					xwt_proj = null;
					foreach (var item in solution.GetAllProjectsWithFlavor<DotNetProjectExtension>()) {
						if (item.ItemId.ToUpper () == "{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}") {
							xwt_proj = item as DotNetProject;
							break;
						}
					}
				}

				var xwt_path = xwt_proj == null ? solution.BaseDirectory.Combine ("Xwt") : xwt_proj.BaseDirectory.ParentDirectory;

				monitor.BeginTask ("Configuring Xwt References...", 3);

				if (xwt_proj == null && !Directory.Exists (xwt_path)) {
					monitor.BeginTask ("Cloning Xwt into " + xwt_path + "...", 1);
					if (createSubmodule && gitRepo != null) {
						monitor.BeginTask ("Initializing Xwt submodule in " + xwt_path + "...", 1);

						var repo = new FileRepository (gitRepo.RootPath.Combine (".git"));
						var git = new Git (repo);

						try {
							using (var gm = new GitMonitor (monitor)) {
								var add_submodule = git.SubmoduleAdd ();
								add_submodule.SetPath ("Xwt");
								add_submodule.SetURI (gitUrl);
								add_submodule.SetProgressMonitor (gm);
								add_submodule.Call ();

								var submodule = new GitRepository (VersionControlService.GetVersionControlSystems ().First (id => id.Name == "Git"),
												   gitRepo.RootPath.Combine ("Xwt"), gitUrl);

								var submoduleRemote = submodule.GetCurrentRemote ();
								submodule.Fetch (monitor, submoduleRemote);
								if (submodule.GetCurrentBranch () != gitBranch) {
									submodule.CreateBranch (gitBranch, submoduleRemote + "/" + gitBranch, "refs/remotes/" + submoduleRemote + "/" + gitBranch);
									submodule.SwitchToBranch (monitor, gitBranch);
								}
							}
						} catch {
							Directory.Delete (xwt_path, true);
							throw;
						}

						monitor.EndTask ();
					} else {

						var repo = new GitRepository ();
						repo.Url = gitUrl;
						repo.Checkout (xwt_path, true, monitor);
						var remote = repo.GetCurrentRemote ();
						repo.Fetch (monitor, remote);
						if (repo.GetCurrentBranch () != gitBranch) {
							repo.CreateBranch (gitBranch, remote + "/" + gitBranch, "refs/remotes/" + remote + "/" + gitBranch);
							repo.SwitchToBranch (monitor, gitBranch);
						}
					}
					monitor.EndTask ();
				}

				SolutionFolder xwt_folder;
				if (xwt_proj != null)
					xwt_folder = xwt_proj.ParentFolder;
				else {
					xwt_folder = new SolutionFolder ();
					xwt_folder.Name = "Xwt";
				}
				solution.RootFolder.Items.Add (xwt_folder);
				monitor.Step (1);

				monitor.BeginTask ("Adding Xwt Projects to Solution...", 7);

				if (xwt_proj == null && File.Exists (xwt_path.Combine ("Xwt", "Xwt.csproj"))) {
					xwt_proj = await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt", "Xwt.csproj")
					) as DotNetProject;
				}
				if (xwt_proj == null)
					throw new InvalidOperationException ("Xwt project not found");

				monitor.Step (1);

				var xwt_gtk_proj = solution.FindProjectByName ("Xwt.Gtk") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk", "Xwt.Gtk.csproj")
					) as DotNetProject;

//.........这里部分代码省略.........
开发者ID:sevoku,项目名称:MonoDevelop.Xwt,代码行数:101,代码来源:XwtTemplateWizard.cs

示例5: ResolveProject

		/// <summary>
		/// Resolves a project for a ReferenceType.Project reference type in a given solution.
		/// </summary>
		/// <returns>The project, or <c>null</c> if it couldn't be resolved.</returns>
		/// <param name="inSolution">The solution the project is in.</param>
		/// <exception cref="T:System.ArgumentNullException">Thrown if inSolution == null</exception>
		/// <exception cref="T:System.InvalidOperationException">Thrown if ReferenceType != ReferenceType.Project</exception>
		public Project ResolveProject (Solution inSolution)
		{
			if (inSolution == null)
				throw new ArgumentNullException ("inSolution");
			if (ReferenceType != ReferenceType.Project)
				throw new InvalidOperationException ("ResolveProject is only definied for Project reference type.");
			if (!string.IsNullOrEmpty (projectGuid)) {
				var project = inSolution.GetSolutionItem (projectGuid) as Project;
				if (project != null) {
					return project;
				}
			}
			return inSolution.FindProjectByName (Reference);
		}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:21,代码来源:ProjectReference.cs

示例6: ModelQueries

		public void ModelQueries ()
		{
			DotNetProject it2, it3, it4;
			DummySolutionItem it1;
			string someFile, someId;
			
			Workspace ws = new Workspace ();
			Workspace cws = new Workspace ();
			ws.Items.Add (cws);
			
			Solution sol1 = new Solution ();
			cws.Items.Add (sol1);
			sol1.RootFolder.Items.Add (it1 = new DummySolutionItem ());
			sol1.RootFolder.Items.Add (it2 = Services.ProjectService.CreateDotNetProject ("C#"));
			
			Solution sol2 = new Solution ();
			cws.Items.Add (sol2);
			SolutionFolder f = new SolutionFolder ();
			sol2.RootFolder.Items.Add (f);
			f.Items.Add (it3 = Services.ProjectService.CreateDotNetProject ("C#"));
			f.Items.Add (it4 = Services.ProjectService.CreateDotNetProject ("C#"));
			
			it3.Name = "it3";
			it4.FileName = "/test/it4";
			someFile = it4.FileName;
			someId = it3.ItemId;
			Assert.IsFalse (string.IsNullOrEmpty (someId));
			
			Assert.AreEqual (2, sol1.Items.Count);
			Assert.IsTrue (sol1.Items.Contains (it1));
			Assert.IsTrue (sol1.Items.Contains (it2));
			
			Assert.AreEqual (2, sol2.Items.Count);
			Assert.IsTrue (sol2.Items.Contains (it3));
			Assert.IsTrue (sol2.Items.Contains (it4));
			
			var its = ws.GetAllItems<SolutionFolderItem> ().ToList();
			Assert.AreEqual (7, its.Count);
			Assert.IsTrue (its.Contains (it1));
			Assert.IsTrue (its.Contains (it2));
			Assert.IsTrue (its.Contains (it3));
			Assert.IsTrue (its.Contains (it4));
			Assert.IsTrue (its.Contains (sol1.RootFolder));
			Assert.IsTrue (its.Contains (sol2.RootFolder));
			Assert.IsTrue (its.Contains (f));
			
			var its2 = ws.GetAllItems<DotNetProject> ().ToList();
			Assert.AreEqual (3, its2.Count);
			Assert.IsTrue (its2.Contains (it2));
			Assert.IsTrue (its2.Contains (it3));
			Assert.IsTrue (its2.Contains (it4));
			
			var its3 = ws.GetAllItems<Project> ().ToList();
			Assert.AreEqual (3, its3.Count);
			Assert.IsTrue (its3.Contains (it2));
			Assert.IsTrue (its3.Contains (it3));
			Assert.IsTrue (its3.Contains (it4));
			
			var its4 = ws.GetAllItems<Solution> ().ToList();
			Assert.AreEqual (2, its4.Count);
			Assert.IsTrue (its4.Contains (sol1));
			Assert.IsTrue (its4.Contains (sol2));
			
			var its5 = ws.GetAllItems<WorkspaceItem> ().ToList();
			Assert.AreEqual (4, its5.Count);
			Assert.IsTrue (its5.Contains (ws));
			Assert.IsTrue (its5.Contains (cws));
			Assert.IsTrue (its5.Contains (sol2));
			Assert.IsTrue (its5.Contains (sol2));
			
			var its6 = ws.GetAllItems<Workspace> ().ToList();
			Assert.AreEqual (2, its6.Count);
			Assert.IsTrue (its6.Contains (ws));
			Assert.IsTrue (its6.Contains (cws));
			
			SolutionFolderItem si = sol2.GetSolutionItem (someId);
			Assert.AreEqual (it3, si);
			
			SolutionItem fi = sol2.FindSolutionItem (someFile);
			Assert.AreEqual (it4, fi);
			
			fi = sol2.FindProjectByName ("it3");
			Assert.AreEqual (it3, fi);
			
			fi = sol2.FindProjectByName ("it4");
			Assert.AreEqual (it4, fi);
			
			fi = sol2.FindProjectByName ("it2");
			Assert.IsNull (fi);
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:90,代码来源:WorkspaceTests.cs

示例7: GetProjectFromName

		Project GetProjectFromName (string name, Solution targetSolution)
		{
			Project refp = null;
			if (targetSolution != null) refp = targetSolution.FindProjectByName (name);

			if (refp == null)
				throw new Exception ( GettextCatalog.GetString ("Couldn't find referenced project '{0}'", 
							name ) );
			
			return refp;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:11,代码来源:SimpleProjectMakefileHandler.cs


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