-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for dynamic types like expando object #36 #37
base: master
Are you sure you want to change the base?
Conversation
Added validation if object inherits (or is) an IDictionary<string, object>, and return the value if the key exists
I cannot accept this PR for these reasons:
As I understand only change that is actually needed is
To avoid possible misuse of other You may change your PR to include only this change (+ add a unit test for it) or I may add support for expando object by myself. |
Ah, sorry, I thought the pull request would only contain the first commit 09ffd3b, not the others. So yes, the change you quoted is the only change I suggest. I had to add the other changes to get it to run correctly for my situation, but just temporary.
I'm not sure what would happen with a dynamic object, and if it that would work with IDictionary too. So as ExpandoObject would be better. After using this change I actually ran into another (logical) problem. Expando properties can have "-" symbols in their name. This won't work in LambdaParser, as it will (and I'm guessing) resolve in minus, instead of a string value. For example, I added a property "ODO-BMI-T-MC", and an expression like "diploma.ODO-BMI-T-MC == true" (where diploma is the expand object). |
Since ExpandoObject implements IDictionary<string,object> you can access its properties simply like any other (real) dictionary? If this works it seems no need to add special support for ExpandoObject at all. |
True, therefor I added a "safe" dictionary, which won't give exceptions on missing keys. So indeed, expandoObject won't be necessary at this moment, although I prefer expressions without [ ], to keep it clean for the users. I'll remove my fork and please drop the request. |
Added validation if object inherits (or is) an IDictionary<string, object>, and return the value if the key exists