Skip to content

Commit

Permalink
Better NCalc extension method with pre-configured options (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucioPelinson authored Apr 27, 2024
1 parent 9d367b4 commit 2a28d46
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,23 @@ public static MasterDataServiceBuilder WithNCalcExpressionProvider(this MasterDa

return builder;
}

public static MasterDataServiceBuilder WithNCalcExpression(this MasterDataServiceBuilder builder)
{
builder.WithNCalcExpressionProvider(new NCalcExpressionProviderOptions
{
ReplaceDefaultExpressionProvider = true,
AdditionalFunctions =
[
(name, args) =>
{
if (name == "now")
args.Result = DateTime.Now;
}
]
});

return builder;
}

}

0 comments on commit 2a28d46

Please sign in to comment.