本文整理匯總了C#中Mono.Cecil.Cil.ILProcessor.Copy方法的典型用法代碼示例。如果您正苦於以下問題:C# ILProcessor.Copy方法的具體用法?C# ILProcessor.Copy怎麽用?C# ILProcessor.Copy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mono.Cecil.Cil.ILProcessor
的用法示例。
在下文中一共展示了ILProcessor.Copy方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: WeaveOnComplete
private void WeaveOnComplete(MethodDefinition targetMethod, ILProcessor ilp, VariableDefinition aspectInstance, VariableDefinition correlation)
{
if (_onComplete != null)
{
var last = targetMethod.Body.Instructions.Last();
if (last.OpCode == OpCodes.Ret)
{
var insertBefore = last.Previous;
while (insertBefore.OpCode != OpCodes.Nop && insertBefore.OpCode != OpCodes.Br_S)
{
insertBefore = insertBefore.Previous;
}
Instruction loadReturn = null;
//if it's a br_s then we are returning a value.
if (insertBefore.OpCode == OpCodes.Br_S)
{
loadReturn = ilp.Copy(insertBefore.Next);
}
var onCompleteInstructions = GetOnCompleteInstructions(targetMethod, ilp, aspectInstance, correlation, loadReturn).ToArray();
//Place this code before the last nop or br_s so that the onException can place itself correctly.
ilp.InsertInstructionsBefore(insertBefore, onCompleteInstructions);
}
}
}