本文整理汇总了C#中Mono.Cecil.Cil.CilWorker.Stind方法的典型用法代码示例。如果您正苦于以下问题:C# CilWorker.Stind方法的具体用法?C# CilWorker.Stind怎么用?C# CilWorker.Stind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.Cil.CilWorker
的用法示例。
在下文中一共展示了CilWorker.Stind方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveRefArguments
/// <summary>
/// Saves the ref arguments of a given method using the
/// <paramref name="arguments"/> from the <paramref name="invocationInfo"/>
/// object.
/// </summary>
/// <param name="IL">The <see cref="CilWorker"/> that will emit the method body.</param>
/// <param name="parameters">The parameters of the target method.</param>
/// <param name="invocationInfo">The local variable that contains the <see cref="IInvocationInfo"/> instance.</param>
/// <param name="arguments">The local variable that will store the arguments from the <see cref="IInvocationInfo"/> instance.</param>
private static void SaveRefArguments(CilWorker IL, IEnumerable<ParameterDefinition> parameters,
VariableDefinition invocationInfo, VariableDefinition arguments)
{
var body = IL.GetBody();
var targetMethod = body.Method;
var declaringType = targetMethod.DeclaringType;
var module = declaringType.Module;
// Save the arguments returned from the handler method
var getArguments = module.ImportMethod<IInvocationInfo>("get_Arguments");
IL.Emit(OpCodes.Ldloc, invocationInfo);
IL.Emit(OpCodes.Callvirt, getArguments);
IL.Emit(OpCodes.Stloc, arguments);
var index = 0;
foreach (var param in parameters)
{
if (!param.IsByRef())
{
index++;
continue;
}
// Load the destination address
IL.Emit(OpCodes.Ldarg, index + 1);
// Load the argument value
IL.Emit(OpCodes.Ldloc, arguments);
IL.Emit(OpCodes.Ldc_I4, index++);
IL.Emit(OpCodes.Ldelem_Ref);
// Determine the actual parameter type
var referenceType = param.ParameterType as ReferenceType;
if (referenceType == null)
continue;
var actualParameterType = referenceType.ElementType;
IL.Emit(OpCodes.Unbox_Any, actualParameterType);
IL.Stind(param.ParameterType);
}
}