Class DynXHelper
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
MethodInfotarget
object
Returns
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
stringctxType
ParameterExpressionretType
TypefuncLib
IReadOnlyDictionary<string, object>ctxConverter
IReadOnlyDictionary<string, Type>
Returns
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>)
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
stringfuncLib
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
stringexprParams
IEnumerable<ParameterExpression>retType
TypefuncLib
IReadOnlyDictionary<string, object>
Returns
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
stringretType
TypefuncLib
IReadOnlyDictionary<string, object>
Returns
Type Parameters
TCtx