mparlak / Flee

Fast Lightweight Expression Evaluator
607 stars 119 forks source link

Using DynamicObject as Expression Owner #78

Open themightylc opened 4 years ago

themightylc commented 4 years ago

I seem to be unable to use a DynamicObject (IExpando, IDynamic) with dynamic members as Expression owner. At runtime, (property) member foo exits and can be evaluated by .NET, but using it as Expression owner results in

Flee.PublicTypes.ExpressionCompileException IdentifierElement: Could not find a field/property/variable with the name 'foo'

Is this intended? Do I need to wrap the Object and write a member accessor?

hunkydoryrepair commented 3 years ago

Flee uses reflection and DynamicObject properties are not properties visible by reflection. You can add variables at runtime to the context, or you can implement a function to access dynamic properties.

eng-marani commented 2 years ago

I'm facing too the same issue. Extending flee to allow expando objects to be understood as properties would be a very handy feature. A diffferent approach would be to decorate a specific function on the owner where to pass statically the property name as string every time it is not resolved by reflection, so i can calculate the result runtime even without involving any expando object to be pre-filled. Is this project actively maintained ? I would love to collaborate for implementing such a feature.