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


C# MonoDevelop.GetReferencedAssemblies方法代码示例

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


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

示例1: CreateMetadataReferences

		static async Task<List<MetadataReference>> CreateMetadataReferences (MonoDevelop.Projects.DotNetProject netProject, ProjectId projectId, CancellationToken token)
		{
			List<MetadataReference> result = new List<MetadataReference> ();
			
			var configurationSelector = IdeApp.Workspace?.ActiveConfiguration ?? MonoDevelop.Projects.ConfigurationSelector.Default;
			var hashSet = new HashSet<string> (FilePath.PathComparer);

			try {
				foreach (string file in await netProject.GetReferencedAssemblies (configurationSelector, false).ConfigureAwait (false)) {
					if (token.IsCancellationRequested)
						return result;
					string fileName;
					if (!Path.IsPathRooted (file)) {
						fileName = Path.Combine (Path.GetDirectoryName (netProject.FileName), file);
					} else {
						fileName = Path.GetFullPath (file);
					}
					if (hashSet.Contains (fileName))
						continue;
					hashSet.Add (fileName);
					if (!File.Exists (fileName)) {
						LoggingService.LogError ("Error while getting referenced Assembly " + fileName + " for project " + netProject.Name + ": File doesn't exist"); 
						continue;
					}
					var metadataReference = MetadataReferenceCache.LoadReference (projectId, fileName);
					if (metadataReference == null)
						continue;
					result.Add (metadataReference);
				}
			} catch (Exception e) {
				LoggingService.LogError ("Error while getting referenced assemblies", e);
			}

			foreach (var pr in netProject.GetReferencedItems (configurationSelector)) {
				if (token.IsCancellationRequested)
					return result;
				var referencedProject = pr as MonoDevelop.Projects.DotNetProject;
				if (referencedProject == null)
					continue;
				if (TypeSystemService.IsOutputTrackedProject (referencedProject)) {
					var fileName = referencedProject.GetOutputFileName (configurationSelector);
					if (!File.Exists (fileName)) {
						LoggingService.LogError ("Error while getting project Reference (" + referencedProject.Name + ") " + fileName + " for project " + netProject.Name + ": File doesn't exist");
						continue;
					}
					var metadataReference = MetadataReferenceCache.LoadReference (projectId, fileName);
					if (metadataReference != null)
						result.Add (metadataReference);
				}
			}
			return result;
		}
开发者ID:anhlehoang410,项目名称:monodevelop,代码行数:52,代码来源:MonoDevelopWorkspace.cs

示例2: CreateMetadataReferences

		static async Task<List<MetadataReference>> CreateMetadataReferences (MonoDevelop.Projects.DotNetProject netProject, ProjectId projectId, CancellationToken token)
		{
			List<MetadataReference> result = new List<MetadataReference> ();
			
			var configurationSelector = IdeApp.Workspace?.ActiveConfiguration ?? MonoDevelop.Projects.ConfigurationSelector.Default;
			var hashSet = new HashSet<string> (FilePath.PathComparer);

			bool addFacadeAssemblies = false;

			try {
				foreach (string file in await netProject.GetReferencedAssemblies (configurationSelector, false).ConfigureAwait (false)) {
					if (token.IsCancellationRequested)
						return result;
					string fileName;
					if (!Path.IsPathRooted (file)) {
						fileName = Path.Combine (Path.GetDirectoryName (netProject.FileName), file);
					} else {
						fileName = Path.GetFullPath (file);
					}
					if (hashSet.Contains (fileName))
						continue;
					hashSet.Add (fileName);
					if (!File.Exists (fileName))
						continue;
					result.Add (MetadataReferenceCache.LoadReference (projectId, fileName));
					addFacadeAssemblies |= MonoDevelop.Core.Assemblies.SystemAssemblyService.ContainsReferenceToSystemRuntime (fileName);
				}
			} catch (Exception e) {
				LoggingService.LogError ("Error while getting referenced assemblies", e);
			}
			// HACK: Facade assemblies should be added by the project system. Remove that when the project system can do that.
			if (addFacadeAssemblies) {
				if (netProject != null) {
					var runtime = netProject.TargetRuntime ?? MonoDevelop.Core.Runtime.SystemAssemblyService.DefaultRuntime;
					var facades = runtime.FindFacadeAssembliesForPCL (netProject.TargetFramework);
					foreach (var facade in facades) {
						if (!File.Exists (facade))
							continue;
						result.Add (MetadataReferenceCache.LoadReference (projectId, facade));
					}
				}
			}

			foreach (var pr in netProject.GetReferencedItems (configurationSelector)) {
				if (token.IsCancellationRequested)
					return result;
				var referencedProject = pr as MonoDevelop.Projects.DotNetProject;
				if (referencedProject == null)
					continue;
				if (TypeSystemService.IsOutputTrackedProject (referencedProject)) {
					var fileName = referencedProject.GetOutputFileName (configurationSelector);
					if (!File.Exists (fileName))
						continue;
					result.Add (MetadataReferenceCache.LoadReference (projectId, fileName));
				}
			}
			return result;
		}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:58,代码来源:MonoDevelopWorkspace.cs


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