本文整理汇总了C#中System.Reflection.PortableExecutable.PEReader.GetEmbeddedReferences方法的典型用法代码示例。如果您正苦于以下问题:C# PEReader.GetEmbeddedReferences方法的具体用法?C# PEReader.GetEmbeddedReferences怎么用?C# PEReader.GetEmbeddedReferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.PortableExecutable.PEReader
的用法示例。
在下文中一共展示了PEReader.GetEmbeddedReferences方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExpandEmbeddedReferences
private static void ExpandEmbeddedReferences(ICache cache, IList<IMetadataReference> references)
{
var otherReferences = new List<IMetadataReference>();
foreach (var reference in references)
{
var fileReference = reference as IMetadataFileReference;
if (fileReference != null &&
string.Equals(Path.GetExtension(fileReference.Path), ".dll", StringComparison.OrdinalIgnoreCase))
{
// We don't use the exact path since that might clash with another key
var key = "ANI_" + fileReference.Path;
var embeddedRefs = cache.Get<IList<IMetadataEmbeddedReference>>(key, ctx =>
{
ctx.Monitor(new FileWriteTimeCacheDependency(fileReference.Path));
using (var fileStream = File.OpenRead(fileReference.Path))
using (var reader = new PEReader(fileStream))
{
return reader.GetEmbeddedReferences();
}
});
otherReferences.AddRange(embeddedRefs);
}
}
references.AddRange(otherReferences);
}
示例2: ExpandEmbeddedReferences
private static void ExpandEmbeddedReferences(IList<IMetadataReference> references)
{
var otherReferences = new List<IMetadataReference>();
foreach (var reference in references)
{
var fileReference = reference as IMetadataFileReference;
if (fileReference != null)
{
using (var fileStream = File.OpenRead(fileReference.Path))
using (var reader = new PEReader(fileStream))
{
otherReferences.AddRange(reader.GetEmbeddedReferences());
}
}
}
references.AddRange(otherReferences);
}