本文整理汇总了C#中MonoDevelop.GetReferencedItems方法的典型用法代码示例。如果您正苦于以下问题:C# MonoDevelop.GetReferencedItems方法的具体用法?C# MonoDevelop.GetReferencedItems怎么用?C# MonoDevelop.GetReferencedItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoDevelop
的用法示例。
在下文中一共展示了MonoDevelop.GetReferencedItems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateProjectReferences
IEnumerable<ProjectReference> CreateProjectReferences (MonoDevelop.Projects.Project p, CancellationToken token)
{
foreach (var pr in p.GetReferencedItems (MonoDevelop.Projects.ConfigurationSelector.Default)) {
if (token.IsCancellationRequested)
yield break;
var referencedProject = pr as MonoDevelop.Projects.DotNetProject;
if (referencedProject == null)
continue;
if (TypeSystemService.IsOutputTrackedProject (referencedProject))
continue;
yield return new ProjectReference (GetOrCreateProjectId (referencedProject));
}
}
示例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);
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;
}
示例3: CreateMetadataReferences
static async Task<List<MetadataReference>> CreateMetadataReferences (MonoDevelop.Projects.Project p, ProjectId projectId, CancellationToken token)
{
List<MetadataReference> result = new List<MetadataReference> ();
var netProject = p as MonoDevelop.Projects.DotNetProject;
if (netProject == null)
return result;
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 p.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;
}