Table of Contents

Struct ExpressionExtensions.ForEachLoopExpressionCreator

Namespace
LfrlAnvil.Extensions
Assembly
LfrlAnvil.Core.dll

A lightweight creator of an Expression node equivalent to a foreach loop.

public readonly struct ExpressionExtensions.ForEachLoopExpressionCreator
Inherited Members
Extension Methods

Properties

Current

ParameterExpression representing a local variable that can have the Current value assigned to it.

public ParameterExpression Current { get; }

Property Value

ParameterExpression

CurrentAssignment

BinaryExpression representing an assignment of the Current value to the Current local variable.

public BinaryExpression CurrentAssignment { get; }

Property Value

BinaryExpression

CurrentProperty

PropertyInfo instance representing enumerator's Current property.

public PropertyInfo CurrentProperty { get; }

Property Value

PropertyInfo

Methods

Create(Expression, string?)

Creates a new BlockExpression that represents a foreach loop.

[Pure]
public BlockExpression Create(Expression body, string? loopBreakLabelName = "ForEachEnd")

Parameters

body Expression

Loop's body expression.

loopBreakLabelName string

Optional name of the LabelTarget that represents the loop's break. Equal to "ForEachEnd" by default.

Returns

BlockExpression

New BlockExpression instance.

Remarks

Use Current and CurrentAssignment properties to construct the desired loop body.