You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
using EC.Helper.RabbitFunc.Runtime;
|
|
using MissingMemberException = EC.Helper.RabbitFunc.Runtime.MissingMemberException;
|
|
|
|
namespace EC.Helper.RabbitFunc.Expressions;
|
|
|
|
public class ParameterExpression : Expression
|
|
{
|
|
internal ParameterExpression(ExpressionType nodeType, Type type, string name)
|
|
: base(nodeType)
|
|
{
|
|
Type = type;
|
|
Name = name;
|
|
}
|
|
|
|
public override Type Type { get; }
|
|
|
|
public string Name { get; }
|
|
|
|
internal static object Access(RuntimeContext context, string name)
|
|
{
|
|
var value = context.Access(name);
|
|
if (value == null)
|
|
throw new MissingMemberException(string.Format("missing member:{0}", name));
|
|
|
|
return value.Value;
|
|
}
|
|
|
|
internal static T Access<T>(RuntimeContext context, string name)
|
|
{
|
|
return (T)Access(context, name);
|
|
}
|
|
|
|
public override object Eval(RuntimeContext context)
|
|
{
|
|
if (context == null)
|
|
throw new ArgumentNullException(nameof(context));
|
|
|
|
return Access(context, Name);
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return Name;
|
|
}
|
|
}
|