本文整理汇总了C#中System.Reflection.ParameterInfo.Zip方法的典型用法代码示例。如果您正苦于以下问题:C# ParameterInfo.Zip方法的具体用法?C# ParameterInfo.Zip怎么用?C# ParameterInfo.Zip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.ParameterInfo
的用法示例。
在下文中一共展示了ParameterInfo.Zip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitDynamicMethodInvokeBinder
/// <summary>
/// Emits the dynamic method invoke binder.
/// </summary>
/// <param name="generator">The generator.</param>
/// <param name="flag">The binding flags.</param>
/// <param name="name">The name.</param>
/// <param name="context">The context.</param>
/// <param name="argInfo">The arg info.</param>
/// <param name="argNames">The arg names.</param>
public static void EmitDynamicMethodInvokeBinder(this ILGenerator generator, CSharpBinderFlags flag, string name, IEnumerable<Type> genericParms, Type context, ParameterInfo[] argInfo, IEnumerable<string> argNames)
{
if (genericParms != null && !genericParms.Any())
genericParms = null;
generator.Emit(OpCodes.Ldc_I4, (int)flag);
generator.Emit(OpCodes.Ldstr, name);
if (genericParms == null)
{
generator.Emit(OpCodes.Ldnull);
}
else
{
generator.EmitArray(typeof(Type), genericParms.Select(arg => (Action<ILGenerator>)(gen => gen.EmitTypeOf(arg))).ToList());
}
generator.EmitTypeOf(context);
var tList = new List<Action<ILGenerator>> { gen => gen.EmitCreateCSharpArgumentInfo(CSharpArgumentInfoFlags.None) };
tList.AddRange(argInfo.Zip(argNames,(p,n)=>new{p,n}).Select(arg => (Action<ILGenerator>)(gen =>
{
var tStart = CSharpArgumentInfoFlags.
UseCompileTimeType;
if (arg.p.IsDefined(typeof(DynamicAttribute), true))
{
tStart = CSharpArgumentInfoFlags.None;
}
if (arg.p.IsOut)
{
tStart |=
CSharpArgumentInfoFlags.IsOut;
}
else if(arg.p.ParameterType.IsByRef)
{
tStart |=
CSharpArgumentInfoFlags.IsRef;
}
if (!String.IsNullOrEmpty(arg.n))
{
tStart |=
CSharpArgumentInfoFlags.NamedArgument;
}
gen.EmitCreateCSharpArgumentInfo(tStart, arg.n);
return;
})));
generator.EmitArray(typeof(CSharpArgumentInfo), tList);
generator.Emit(OpCodes.Call, typeof(Binder).GetMethod("InvokeMember", new[] { typeof(CSharpBinderFlags), typeof(string), typeof(IEnumerable<Type>), typeof(Type), typeof(CSharpArgumentInfo[]) }));
}