Class ExpressionTupletizer
Provides a set of methods to pack and unpack expressions into/from tuples.
Inheritance
Namespace: System.Linq.CompilerServices
Assembly: Nuqleon.Linq.CompilerServices.dll
Syntax
public static class ExpressionTupletizer : Object
Methods
IsTuple(Type)
Checks whether the specified type is a packed tuple.
Declaration
public static bool IsTuple(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | Type to check. |
Returns
Type | Description |
---|---|
System.Boolean | true if the specified type is a tuple; otherwise, false. |
Pack(IEnumerable<Expression>)
Packs the specified expressions into an expression that creates a tuple of the expressions.
Declaration
public static Expression Pack(IEnumerable<Expression> expressions)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> | expressions | Expressions to pack in a tuple. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.Expression | Expression representing the creation of a tuple of the given expressions. |
Pack(Expression, IEnumerable<ParameterExpression>)
Creates a lambda expression whose parameters are packed in a tuple. If no parameters are specified, a lambda with no parameters is returned. If exactly one parameter is specified, the parameter will get packed in a 1-tuple.
Declaration
public static LambdaExpression Pack(Expression body, IEnumerable<ParameterExpression> parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | body | Body of the lambda expression. Occurrences of the specified parameters will get packed in tuples. |
System.Collections.Generic.IEnumerable<System.Linq.Expressions.ParameterExpression> | parameters | Parameters to be packed into a single lambda parameter. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.LambdaExpression | Lambda expression with parameters packed as a tuple. |
Pack(Expression, IEnumerable<ParameterExpression>, Type)
Creates a lambda expression whose parameters are packed in a tuple. If no parameters are specified, a lambda with a dummy parameter of the specified 'void' type will be returned. If exactly one parameter is specified, the parameter will get packed in a 1-tuple.
Declaration
public static LambdaExpression Pack(Expression body, IEnumerable<ParameterExpression> parameters, Type voidType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | body | Body of the lambda expression. Occurrences of the specified parameters will get packed in tuples. |
System.Collections.Generic.IEnumerable<System.Linq.Expressions.ParameterExpression> | parameters | Parameters to be packed into a single lambda parameter. |
System.Type | voidType | Type used to represent an empty parameter list as a single 'void' parameter. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.LambdaExpression | Lambda expression with parameters packed as a tuple. |
Pack(LambdaExpression)
Packs the lambda expression parameters into a tuple. If the lambda expression has no parameters, this method is a no-op. If the lambda expression has exactly one parameter, the parameter will get packed in a 1-tuple.
Declaration
public static LambdaExpression Pack(LambdaExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.LambdaExpression | expression | Expression to pack parameters for. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.LambdaExpression | Lambda expression with parameters packed as a tuple. |
Pack(LambdaExpression, Type)
Packs the lambda expression parameters into a tuple. If the lambda expression has no parameters, a dummy parameter of the specified 'void' type will be inserted. If the lambda expression has exactly one parameter, the parameter will get packed in a 1-tuple.
Declaration
public static LambdaExpression Pack(LambdaExpression expression, Type voidType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.LambdaExpression | expression | Expression to pack parameters for. |
System.Type | voidType | Type used to represent an empty parameter list as a single 'void' parameter. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.LambdaExpression | Lambda expression with parameters packed as a tuple. |
Unpack(Expression)
Unpacks the specified expression representing a tuple into the expressions of its components.
Declaration
public static IEnumerable<Expression> Unpack(Expression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression | expression | Expression to unpack into its component expressions. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression> | Expressions representing the components of the tuple represented by the given expression. |
Unpack(LambdaExpression)
Unpacks the lambda expression with a tuple-based parameter into a lambda expression with parameters for the tuple components. If the lambda expression has no parameters, this method is a no-op.
Declaration
public static LambdaExpression Unpack(LambdaExpression expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.LambdaExpression | expression | Expression to unpack the tuple-based parameter into parameters for its components. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.LambdaExpression | Lambda expression with parameters unpacked from the tuple-based parameter. |
Unpack(LambdaExpression, out Expression, out IEnumerable<ParameterExpression>)
Unpacks the lambda expression with a tuple-based parameter into a lambda body and its set of parameters.
Declaration
public static void Unpack(LambdaExpression expression, out Expression body, out IEnumerable<ParameterExpression> parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.LambdaExpression | expression | Expression to unpack the tuple-based parameter into parameters for its components. |
System.Linq.Expressions.Expression | body | Lambda body with parameters unpacked from the tuple-based parameter. |
System.Collections.Generic.IEnumerable<System.Linq.Expressions.ParameterExpression> | parameters | The set of parameters that occur in the lambda body. |
Unpack(LambdaExpression, Type)
Unpacks the lambda expression with a tuple-based parameter into a lambda expression with parameters for the tuple components. If the lambda expression has no parameters, this method is a no-op. If the lambda expression has one parameter of the specified 'void' type, it will get unpacked into a lambda expression with no parameters.
Declaration
public static LambdaExpression Unpack(LambdaExpression expression, Type voidType)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.LambdaExpression | expression | Expression to unpack the tuple-based parameter into parameters for its components. |
System.Type | voidType | Type used to represent an empty parameter list as a single 'void' parameter. |
Returns
Type | Description |
---|---|
System.Linq.Expressions.LambdaExpression | Lambda expression with parameters unpacked from the tuple-based parameter. |
Unpack(LambdaExpression, Type, out Expression, out IEnumerable<ParameterExpression>)
Unpacks the lambda expression with a tuple-based parameter into a lambda body and its set of parameters.
Declaration
public static void Unpack(LambdaExpression expression, Type voidType, out Expression body, out IEnumerable<ParameterExpression> parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.LambdaExpression | expression | Expression to unpack the tuple-based parameter into parameters for its components. |
System.Type | voidType | Type used to represent an empty parameter list as a single 'void' parameter. |
System.Linq.Expressions.Expression | body | Lambda body with parameters unpacked from the tuple-based parameter. |
System.Collections.Generic.IEnumerable<System.Linq.Expressions.ParameterExpression> | parameters | The set of parameters that occur in the lambda body. |