本文整理汇总了C#中Instruction.GetPreviousSequencePoint方法的典型用法代码示例。如果您正苦于以下问题:C# Instruction.GetPreviousSequencePoint方法的具体用法?C# Instruction.GetPreviousSequencePoint怎么用?C# Instruction.GetPreviousSequencePoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Instruction
的用法示例。
在下文中一共展示了Instruction.GetPreviousSequencePoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLineNumber
string GetLineNumber(Instruction instruction)
{
var sequencePoint = instruction.GetPreviousSequencePoint();
if (sequencePoint == null)
{
return null;
}
return sequencePoint.StartLine.ToString();
}
示例2: GetMessagePrefix
string GetMessagePrefix(Instruction instruction)
{
//TODO: should prob wrap calls to this method and not concat an empty string. but this will do for now
if (ModuleWeaver.LogMinimalMessage)
{
return string.Empty;
}
var sequencePoint = instruction.GetPreviousSequencePoint();
if (sequencePoint == null)
{
return string.Format("Method: '{0}'. ", Method.FullName);
}
return string.Format("Method: '{0}'. Line: ~{1}. ", Method.FullName, sequencePoint.StartLine);
}
示例3: FindResource
public Resource FindResource(string searchPath, string @namespace, string codeDirPath, Instruction instruction)
{
var resources = ModuleDefinition.Resources;
//Fully qualified
var resource = resources.FirstOrDefault(x => x.Name == searchPath);
if (resource != null)
{
return resource;
}
//Relative based on namespace
var namespaceCombine = Path.Combine(@namespace.Replace(@"\", ".").Replace(@"\", "."), searchPath);
var resourceNameFromNamespace = namespaceCombine.Replace(@"\", ".").Replace(@"\", ".");
resource = resources.FirstOrDefault(x => x.Name == resourceNameFromNamespace);
if (resource != null)
{
return resource;
}
//Relative based on dir
var fakeDrive = @"C:\";
var dirCombine = Path.GetFullPath(Path.Combine(fakeDrive, codeDirPath, searchPath))
.Replace(fakeDrive,string.Empty);
var suffix = dirCombine
.Replace(@"\", ".")
.Replace(@"\", ".");
var resourceNameFromDir = Path.GetFileNameWithoutExtension(ModuleDefinition.Name) + "." + suffix;
resource = resources.FirstOrDefault(x => x.Name == resourceNameFromDir);
if (resource != null)
{
return resource;
}
var message = $"Could not find a resource.\r\nTried:\r\n'{searchPath}'\r\n'{resourceNameFromDir}'\r\n'{resourceNameFromDir}'";
LogErrorPoint(message, instruction.GetPreviousSequencePoint());
return null;
}