本文整理汇总了C#中ReadOnlyArray.Select方法的典型用法代码示例。如果您正苦于以下问题:C# ReadOnlyArray.Select方法的具体用法?C# ReadOnlyArray.Select怎么用?C# ReadOnlyArray.Select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReadOnlyArray
的用法示例。
在下文中一共展示了ReadOnlyArray.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitMethodArgumentsAndGenerics
private BoundValueType EmitMethodArgumentsAndGenerics(MethodInfo method, ReadOnlyArray<BoundCallArgument> arguments, ReadOnlyArray<BoundExpression> generics)
{
bool needWriteBack = arguments.Any(p => p.IsRef && p.Expression.IsAssignable());
// Load the arguments array.
LocalBuilder arrayLocal = null;
if (arguments.Count > 0 || generics.Count > 0)
{
int count = arguments.Count;
if (generics.Count > 0)
count++;
// Create the array to hold the arguments.
IL.EmitConstant(count);
IL.Emit(OpCodes.Newarr, typeof(object));
// Emit store for the elements.
EmitArrayElementsStore(arguments.Select(p => p.Expression));
// We smuggle the generic arguments into the last entry of the
// arguments array. If we have generic arguments, create a
// JsGenericArguments object to hold them and put it at the end
// of the array.
if (generics.Count > 0)
{
// Dup the array reference for the Stelem. We're going to leave
// the array reference on the stack.
IL.Emit(OpCodes.Dup);
// Emit the index the item is at.
IL.EmitConstant(count - 1);
// Emit the array to hold the generic arguments.
IL.EmitConstant(generics.Count);
IL.Emit(OpCodes.Newarr, typeof(object));
// Store the generic arguments.
EmitArrayElementsStore(generics);
// Emit the JsGenericArguments object.
IL.Emit(OpCodes.Newobj, _genericArgumentsConstructor);
// Store the generic arguments in the array.
IL.Emit(OpCodes.Stelem_Ref);
}
// If we're doing a write back, we need to hold on to a reference
// to the array, so dup the stack element here and store it in
// a local.
if (needWriteBack)
{
arrayLocal = IL.DeclareLocal(typeof(object[]));
IL.Emit(OpCodes.Dup);
IL.Emit(OpCodes.Stloc, arrayLocal);
}
}
else
{
IL.Emit(OpCodes.Ldsfld, _emptyObjectArray);
}
// And execute the method.
IL.EmitCall(method);
// The result is now on the stack, which we leave there as the result
// of this emit.
if (needWriteBack)
{
// We need to read the arguments back for when the ExecuteFunction
// has out parameters for native calls.
for (int i = 0; i < arguments.Count; i++)
{
var argument = arguments[i];
if (!argument.IsRef || !argument.Expression.IsAssignable())
continue;
var valueExpression = new BoundEmitExpression(
BoundValueType.Unknown,
() =>
{
// Load the argument from the array.
IL.Emit(OpCodes.Ldloc, arrayLocal);
IL.EmitConstant(i);
IL.Emit(OpCodes.Ldelem_Ref);
}
);
if (argument.Expression.Kind == BoundKind.GetMember)
{
var getMember = (BoundGetMember)argument.Expression;
EmitSetMember(getMember.Expression, getMember.Index, valueExpression);
}
else
{
//.........这里部分代码省略.........