Questions tagged [dynamic-expresso]
14 questions
2
votes
3 answers
Replace numbers in string to numbers + "f"
I want to make tiny calculator that if you write for example 2/3 and you have got 0.6666667. I use DynamicExpresso.Core library but I need to write 2f/3f to have 0.6666667 (if I write 2/3 I get 0). I think I should use somethink like forCounting =…

Kuba_Z2
- 54
- 1
- 6
2
votes
2 answers
Ability to set the context of the expression
Is there a way to set the context of the expression in Dynamic Expresso library, so that we can do something like the following:
interpreter.Eval("FirstName", new Parameter("person", new { FirstName="Homer", LastName="Simpson"}));
rather…

user3574702
- 21
- 2
1
vote
1 answer
Calculating a String in C#
I want to calculate a string in C# using either NCalc or DynamicExpresso library, the problem is, when the calculation gets complex and the numbers are big, it returns the wrong result.
For example the code below returns -808182895 when it should…

joseph
- 37
- 7
1
vote
0 answers
Parsing expression with unknown number of parameters in DynamicExpreso
Due to performance reasons GitHub page suggests "If you need to run the same expression multiple times with different parameters I suggest to parse it one time and then invoke the parsed expression multiple times."
I have a class like this:
public…

n0e
- 309
- 3
- 12
1
vote
0 answers
How can I use dynamic variables with anonymous types?
I am trying to use dynamic variables containing anonymous types. For example:
var hello = new { french = "bonjour" };
// alternative, dynamic hello
// var hello = new ExpandoObject();
// hello.french = hello
dynamic x = new ExpandoObject();
x.a =…

Niels Harremoes
- 320
- 1
- 18
1
vote
1 answer
Dynamic parameter in parsed expression
A quick sample to understand my situation:
static Interpreter ParseInterpreter = new Interpreter();
...
var func = ParseInterpreter.Parse("ctx.SomeProp", new Parameter("ctx", typeof(???1)).Compile>;
...
var token =…

ProfyTroll
- 281
- 5
- 18
1
vote
1 answer
DynamicExpresso.SetFunction not working with method overload
I'm using Dynamic Expresso for expression evaluation and works like a charm. Actually setting up custom functions, but seems like there is a something wrong with a method overload.
I've actually got two Round methods:
First one with one…

Gonzo345
- 1,133
- 3
- 20
- 42
1
vote
0 answers
Parsing Scientific Notation in dynamic-expresso
Just wondering why parsing of scientific notation was not implemented. I was able to add it with a few simple functions using RegularExpressions. The code scrubs the expression string to replace scientific expression values with double strings prior…

John
- 271
- 3
- 3
1
vote
1 answer
DynamicExpresso Eval memory leak
Is there a solution to avoid memory leak in a simple expression evaluation like this ?
inter.SetVariable("tick", tick++);
if (inter.Eval("(tick%2)==1"))
{
odd++;
if ((odd % 100) == 0)
…

Ezio R.
- 13
- 2
1
vote
2 answers
Using dynamic types with expresso
I would like to use a dynamic value as a parameter.
E.g.
dynamic dyn = new ExpandoObject();
dyn.Foo = "bar";
var bar = new Interpreter().Eval("d.Foo", new Parameter("d", dyn));
Assert.AreEqual("bar", bar.ToString());
But I get an error saying "No…

Niels Harremoes
- 320
- 1
- 18
0
votes
0 answers
Dynamic Expresso: Unknown identifier IDictionary
I am trying to get dynamic expresso to interpret this line of code:
(((IDictionary)o)["Diesel % in oil"].ToString().StartsWith("<") ? ((IDictionary)o)["Diesel % in oil"].ToString().Replace("<", String.Empty) :…

TechyGypo
- 824
- 1
- 11
- 27
0
votes
1 answer
DynamicExpresso : expression as variable
Let's assume we have a variable called TOTAL and it should be replaced with AProperty + BProperty of CClass.
I have an IQueryrable set of CClass objects and I want to select (TOTAL + AProperty) from this set.
AProperty and BProperty are double…

Amin Mozhgani
- 604
- 1
- 7
- 22
0
votes
2 answers
Parse as expression an array containing specific identifier
I am building dynamic lamda expressions from string expressions using ParseAsExpression. The problem is that i cannot figure out how to parse an expression of an array contains an object like mylist.Contains(x.Id)
Full example
var list = new int[]…

George Papadakis
- 1,273
- 13
- 22
0
votes
2 answers
Dynamic expresso foreach with lambda?
I am using Dynamic-Expresso library.
I would like to evaluate expression containing foreach statement.
Is that possible?
The only way I can see is to write parametrized method and send the whole class as a parameter to the Interpreter
var target =…

Vojtěch Dohnal
- 7,867
- 3
- 43
- 105