12 lines
414 B
C#
12 lines
414 B
C#
namespace Bts.BooleanExpressions.Arguments;
|
|
|
|
static class ArgumentExtensions {
|
|
public static IArgument<T> Cast<T>(this IArgument argument) =>
|
|
new Argument<T>(env => {
|
|
var obj = argument.GetValue(env);
|
|
return obj is T t ? t : throw new Exception(
|
|
$"Expected argument.GetValue to return instance of type {typeof(T)} " +
|
|
$"(actually {obj?.GetType()})");
|
|
});
|
|
}
|