Table of Contents

Class DynXHelper

Namespace
Tlabs.Dynamic
Assembly
Tlabs.Core.dll

Dynamic expression helper

public static class DynXHelper
Inheritance
DynXHelper
Inherited Members

Methods

AsDelegate(MethodInfo, object?)

Converts methodInfo into a delegeate

public static Delegate AsDelegate(this MethodInfo methodInfo, object? target = null)

Parameters

methodInfo MethodInfo
target object

Returns

Delegate

BuildExpression(string, ParameterExpression, Type, IReadOnlyDictionary<string, object>, IReadOnlyDictionary<string, Type>)

Parse the expression with access to the public properties of ctxType (and funcLib) returning retType into a Expression that takes ctxType (the context object) as parameter.

public static DynXHelper.ContextExpression BuildExpression(string expression, ParameterExpression ctxType, Type retType, IReadOnlyDictionary<string, object> funcLib, IReadOnlyDictionary<string, Type> ctxConverter)

Parameters

expression string
ctxType ParameterExpression
retType Type
funcLib IReadOnlyDictionary<string, object>
ctxConverter IReadOnlyDictionary<string, Type>

Returns

DynXHelper.ContextExpression

Remarks

In case any of the ctxType's properties should give an object of a dynamically created type (like with CreateType(IList<DynamicProperty>, Type?, string?)):

The property exposed to the expression scope will now get the actual dynamic type given by the ctxConverter.

BuildLambdaExpression<TCtx, TRet>(string, IReadOnlyDictionary<string, object>, IReadOnlyDictionary<string, Type>)

compiled from code with access to the public properties of TCtx (and funcLib) returning TRet.

public static Expression<Func<TCtx, TRet>> BuildLambdaExpression<TCtx, TRet>(string code, IReadOnlyDictionary<string, object> funcLib, IReadOnlyDictionary<string, Type> ctxConverter)

Parameters

code string
funcLib IReadOnlyDictionary<string, object>
ctxConverter IReadOnlyDictionary<string, Type>

Returns

Expression<Func<TCtx, TRet>>

Type Parameters

TCtx
TRet

ParsedExpression(string, IEnumerable<ParameterExpression>, Type, IReadOnlyDictionary<string, object>)

Parse the expression with access to exprParams (and funcLib) returning retType into a LambdaExpression.

public static LambdaExpression ParsedExpression(string expression, IEnumerable<ParameterExpression> exprParams, Type retType, IReadOnlyDictionary<string, object> funcLib)

Parameters

expression string
exprParams IEnumerable<ParameterExpression>
retType Type
funcLib IReadOnlyDictionary<string, object>

Returns

LambdaExpression

ParsedExpression<TCtx>(string, Type, IReadOnlyDictionary<string, object>)

Parse the expression with access to the public properties of TCtx (and funcLib) returning retType into a LambdaExpression.

public static LambdaExpression ParsedExpression<TCtx>(string expression, Type retType, IReadOnlyDictionary<string, object> funcLib)

Parameters

expression string
retType Type
funcLib IReadOnlyDictionary<string, object>

Returns

LambdaExpression

Type Parameters

TCtx