75 lines
2.6 KiB
C#
75 lines
2.6 KiB
C#
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.Reflection;
|
|
using System.Reflection.Emit;
|
|
|
|
namespace System.Linq.Expressions
|
|
{
|
|
/// <summary>Represents an initializer for a single element of an <see cref="T:System.Collections.IEnumerable" /> collection.</summary>
|
|
// Token: 0x02000018 RID: 24
|
|
public sealed class ElementInit
|
|
{
|
|
// Token: 0x06000160 RID: 352 RVA: 0x00009110 File Offset: 0x00007310
|
|
internal ElementInit(MethodInfo add_method, ReadOnlyCollection<Expression> arguments)
|
|
{
|
|
this.add_method = add_method;
|
|
this.arguments = arguments;
|
|
}
|
|
|
|
/// <summary>Gets the instance method that is used to add an element to an <see cref="T:System.Collections.IEnumerable" /> collection.</summary>
|
|
/// <returns>A <see cref="T:System.Reflection.MethodInfo" /> that represents an instance method that adds an element to a collection.</returns>
|
|
// Token: 0x1700001B RID: 27
|
|
// (get) Token: 0x06000161 RID: 353 RVA: 0x00009128 File Offset: 0x00007328
|
|
public MethodInfo AddMethod
|
|
{
|
|
get
|
|
{
|
|
return this.add_method;
|
|
}
|
|
}
|
|
|
|
/// <summary>Gets the collection of arguments that are passed to a method that adds an element to an <see cref="T:System.Collections.IEnumerable" /> collection.</summary>
|
|
/// <returns>A <see cref="T:System.Collections.ObjectModel.ReadOnlyCollection`1" /> of <see cref="T:System.Linq.Expressions.Expression" /> objects that represent the arguments for a method that adds an element to a collection.</returns>
|
|
// Token: 0x1700001C RID: 28
|
|
// (get) Token: 0x06000162 RID: 354 RVA: 0x00009130 File Offset: 0x00007330
|
|
public ReadOnlyCollection<Expression> Arguments
|
|
{
|
|
get
|
|
{
|
|
return this.arguments;
|
|
}
|
|
}
|
|
|
|
/// <summary>Returns a textual representation of an <see cref="T:System.Linq.Expressions.ElementInit" /> object.</summary>
|
|
/// <returns>A textual representation of the <see cref="T:System.Linq.Expressions.ElementInit" /> object.</returns>
|
|
// Token: 0x06000163 RID: 355 RVA: 0x00009138 File Offset: 0x00007338
|
|
public override string ToString()
|
|
{
|
|
return ExpressionPrinter.ToString(this);
|
|
}
|
|
|
|
// Token: 0x06000164 RID: 356 RVA: 0x00009140 File Offset: 0x00007340
|
|
private void EmitPopIfNeeded(EmitContext ec)
|
|
{
|
|
if (this.add_method.ReturnType == typeof(void))
|
|
{
|
|
return;
|
|
}
|
|
ec.ig.Emit(OpCodes.Pop);
|
|
}
|
|
|
|
// Token: 0x06000165 RID: 357 RVA: 0x00009170 File Offset: 0x00007370
|
|
internal void Emit(EmitContext ec, LocalBuilder local)
|
|
{
|
|
ec.EmitCall(local, this.arguments, this.add_method);
|
|
this.EmitPopIfNeeded(ec);
|
|
}
|
|
|
|
// Token: 0x04000062 RID: 98
|
|
private MethodInfo add_method;
|
|
|
|
// Token: 0x04000063 RID: 99
|
|
private ReadOnlyCollection<Expression> arguments;
|
|
}
|
|
}
|