Parsing a string formula by injecting object values (i.e. using reflection) in C#

I need to parse a formula in string format which can contain objects and properties.

Example:

"Person1.Age>20" or "Person1.Age>RentalCar5.MinimumAge"

Where Person1 would be an object of type Person, and RentalCar5 an object of type RentalCar.

I have the objects, so can check the formula contains "Person1" and know it to be a Person object matching that specific Name property, so I need to then determine the ".Age" property needs to be determined, and the whole "Person1.Age" part to be replaced with the object value, such as 21.

Once this is done it would be easy enough to resolve the formula as "21>20"

Any thoughts or ideas?



from Recent Questions - Stack Overflow https://ift.tt/2Tgk1Yl
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation