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


C# Project.GetType方法代码示例

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


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

示例1: SetupProject

		Project SetupProject (ProjectConfigurationInfo[] configurations)
		{
			Project project = null;

			foreach (var pc in configurations) {
				var p = buildEngine.Engine.GetLoadedProject (pc.ProjectFile);
				if (p == null) {
					p = new Project (buildEngine.Engine);
					var content = buildEngine.GetUnsavedProjectContent (pc.ProjectFile);
					if (content == null)
						p.Load (pc.ProjectFile);
					else {
						p.FullFileName = pc.ProjectFile;

						if (HasXbuildFileBug ()) {
							// Workaround for Xamarin bug #14295: Project.Load incorrectly resets the FullFileName property
							var t = p.GetType ();
							t.InvokeMember ("PushThisFileProperty", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, p, new object[] { p.FullFileName });
							t.InvokeMember ("DoLoad", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, p, new object[] { new StringReader (content) });
						} else {
							p.Load (new StringReader (content));
						}
					}
				}
				p.GlobalProperties.SetProperty ("Configuration", pc.Configuration);
				if (!string.IsNullOrEmpty (pc.Platform))
					p.GlobalProperties.SetProperty ("Platform", pc.Platform);
				else
					p.GlobalProperties.RemoveProperty ("Platform");
				if (pc.ProjectFile == file)
					project = p;
			}

			Environment.CurrentDirectory = Path.GetDirectoryName (file);
			return project;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:36,代码来源:ProjectBuilder.cs

示例2: SetupProject

		Project SetupProject (ProjectConfigurationInfo[] configurations)
		{
			Project project = null;

			var slnConfigContents = GenerateSolutionConfigurationContents (configurations);

			foreach (var pc in configurations) {
				var p = buildEngine.Engine.GetLoadedProject (pc.ProjectFile);

				if (p != null && pc.ProjectFile == file) {
					// building the project may create new items and/or modify some properties,
					// so we always need to use a new instance of the project when building
					buildEngine.Engine.UnloadProject (p);
					p = null;
				}

				Environment.CurrentDirectory = Path.GetDirectoryName (Path.GetFullPath (file));

				if (p == null) {
					p = new Project (buildEngine.Engine);
					var content = buildEngine.GetUnsavedProjectContent (pc.ProjectFile);
					if (content == null) {
						p.Load (pc.ProjectFile);
					} else {
						p.FullFileName = Path.GetFullPath (pc.ProjectFile);

						if (HasXbuildFileBug ()) {
							// Workaround for Xamarin bug #14295: Project.Load incorrectly resets the FullFileName property
							var t = p.GetType ();
							t.InvokeMember ("PushThisFileProperty", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, p, new object[] { p.FullFileName });
							t.InvokeMember ("DoLoad", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, p, new object[] { new StringReader (content) });
						} else {
							p.Load (new StringReader (content));
						}
					}
				}

				p.GlobalProperties.SetProperty ("CurrentSolutionConfigurationContents", slnConfigContents);
				p.GlobalProperties.SetProperty ("Configuration", pc.Configuration);
				if (!string.IsNullOrEmpty (pc.Platform))
					p.GlobalProperties.SetProperty ("Platform", pc.Platform);
				else
					p.GlobalProperties.RemoveProperty ("Platform");
				if (pc.ProjectFile == file)
					project = p;
			}

			Environment.CurrentDirectory = Path.GetDirectoryName (Path.GetFullPath (file));
			return project;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:50,代码来源:ProjectBuilder.cs


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